Skip to content

Commit 7f7d830

Browse files
committed
Fixed parser so that square brackets count as delimiters
1 parent 8b20282 commit 7f7d830

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/PHPCR/Util/QOM/Sql2Scanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected function tokenize(&$tokens, $token)
184184
$buffer = '';
185185
for ($i = 0; $i < strlen($token); $i++) {
186186
$char = trim(substr($token, $i, 1));
187-
if (in_array($char, array('.', ',', '(', ')', '='))) {
187+
if (in_array($char, array('[', ']', '.', ',', '(', ')', '='))) {
188188
if ($buffer !== '') {
189189
$tokens[] = $buffer;
190190
$buffer = '';

src/PHPCR/Util/QOM/Sql2ToQomQueryConverter.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -935,9 +935,14 @@ private function fetchTokenWithoutBrackets()
935935
{
936936
$token = $this->scanner->fetchNextToken();
937937

938-
if (substr($token, 0, 1) === '[' && substr($token, -1) === ']') {
939-
// Remove brackets around the selector name
940-
$token = substr($token, 1, -1);
938+
if ($token === '[') {
939+
$token = $this->scanner->fetchNextToken();
940+
$endDelimiter = $this->scanner->fetchNextToken();
941+
if ($endDelimiter !== ']') {
942+
throw new InvalidQueryException(sprintf(
943+
'Expected closing square brackets around "%s"', $token
944+
));
945+
}
941946
}
942947

943948
return $token;

0 commit comments

Comments
 (0)