Skip to content

Commit 9b3f8f2

Browse files
authored
Fix placeholders detection with multiline strings (#658)
1 parent 33e9f47 commit 9b3f8f2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/QueryReflection/QueryReflection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ final class QueryReflection
4242
// see https://github.com/php/php-src/blob/01b3fc03c30c6cb85038250bb5640be3a09c6a32/ext/pdo/pdo_sql_parser.re#L48
4343
private const NAMED_PATTERN = ':[a-zA-Z0-9_]+';
4444

45-
private const REGEX_UNNAMED_PLACEHOLDER = '{(["\'])((?:(?!\1).)*\1)|(' . self::UNNAMED_PATTERN . ')}';
45+
private const REGEX_UNNAMED_PLACEHOLDER = '{(["\'])((?:(?!\1)(?s:.))*\1)|(' . self::UNNAMED_PATTERN . ')}';
4646

47-
private const REGEX_NAMED_PLACEHOLDER = '{(["\'])((?:(?!\1).)*\1)|(' . self::NAMED_PATTERN . ')}';
47+
private const REGEX_NAMED_PLACEHOLDER = '{(["\'])((?:(?!\1)(?s:.))*\1)|(' . self::NAMED_PATTERN . ')}';
4848

4949
/**
5050
* @var QueryReflector|null

tests/rules/data/pdo-stmt-execute-error.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,14 @@ public function supportNestedQuotes(PDO $pdo)
136136
);
137137
$stmt->execute(['value' => 'bar']);
138138
}
139+
140+
public function bug657MultilineString(PDO $pdo)
141+
{
142+
$stmt = $pdo->prepare(<<<SQL
143+
UPDATE `ada` SET email = "multi
144+
line" WHERE `email`= ? AND `email` = "value";
145+
SQL
146+
);
147+
$stmt->execute(['value']);
148+
}
139149
}

0 commit comments

Comments
 (0)