Skip to content

Commit 57f6825

Browse files
committed
BufferedQuery: Backslashes in comments escaped characters in comments.
1 parent 47d03c5 commit 57f6825

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/Utils/BufferedQuery.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@ class BufferedQuery
2929
{
3030

3131
// Constants that describe the current status of the parser.
32-
const STATUS_STRING_SINGLE_QUOTES = 1;
33-
const STATUS_STRING_DOUBLE_QUOTES = 2;
34-
const STATUS_STRING_BACKTICK = 3;
35-
const STATUS_COMMENT_BASH = 4;
36-
const STATUS_COMMENT_C = 5;
37-
const STATUS_COMMENT_SQL = 6;
32+
33+
// A string is being parsed.
34+
const STATUS_STRING = 16; // 0001 0000
35+
const STATUS_STRING_SINGLE_QUOTES = 17; // 0001 0001
36+
const STATUS_STRING_DOUBLE_QUOTES = 18; // 0001 0010
37+
const STATUS_STRING_BACKTICK = 20; // 0001 0100
38+
39+
// A comment is being parsed.
40+
const STATUS_COMMENT = 32; // 0010 0000
41+
const STATUS_COMMENT_BASH = 33; // 0010 0001
42+
const STATUS_COMMENT_C = 34; // 0010 0010
43+
const STATUS_COMMENT_SQL = 36; // 0010 0100
3844

3945
/**
4046
* The query that is being processed.
@@ -193,7 +199,7 @@ public function extract($end = false)
193199
* treated differently, because of the preceding backslash, it will
194200
* be ignored.
195201
*/
196-
if ($this->query[$i] === '\\') {
202+
if (($this->status & static::STATUS_COMMENT == 0) && ($this->query[$i] === '\\')) {
197203
$this->current .= $this->query[$i] . $this->query[++$i];
198204
continue;
199205
}

0 commit comments

Comments
 (0)