diff options
author | Dan Ungureanu <udan1107@gmail.com> | 2015-10-06 23:04:34 +0300 |
---|---|---|
committer | Dan Ungureanu <udan1107@gmail.com> | 2015-10-06 23:11:35 +0300 |
commit | 402890bc7b74534f2150bba7dc40562bf436b085 (patch) | |
tree | 038ccdf003efe1c2e335f1bc3be025ff5e249380 /src/Utils/BufferedQuery.php | |
parent | 4f8868b91ea5ac588205984679ecbed8e2a81677 (diff) | |
download | sql-parser-402890bc7b74534f2150bba7dc40562bf436b085.zip sql-parser-402890bc7b74534f2150bba7dc40562bf436b085.tar.gz sql-parser-402890bc7b74534f2150bba7dc40562bf436b085.tar.bz2 |
Handle backslashes separately for BufferedQuery.v3.0.1
Diffstat (limited to 'src/Utils/BufferedQuery.php')
-rw-r--r-- | src/Utils/BufferedQuery.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php index 1da0b81..7a2e5f4 100644 --- a/src/Utils/BufferedQuery.php +++ b/src/Utils/BufferedQuery.php @@ -186,19 +186,31 @@ class BufferedQuery $loopLen = $end ? $len : $len - 16; for (; $i < $loopLen; ++$i) { + /** + * Handling backslash. + * + * Even if the next character is a special character that should be + * treated differently, because of the preceding backslash, it will + * be ignored. + */ + if ($this->query[$i] === '\\') { + $this->current .= $this->query[$i] . $this->query[++$i]; + continue; + } + /* * Handling special parses statuses. */ if ($this->status === static::STATUS_STRING_SINGLE_QUOTES) { // Single-quoted strings like 'foo'. - if (($this->query[$i - 1] != '\\') && ($this->query[$i] === '\'')) { + if ($this->query[$i] === '\'') { $this->status = 0; } $this->current .= $this->query[$i]; continue; } elseif ($this->status === static::STATUS_STRING_DOUBLE_QUOTES) { // Double-quoted strings like "bar". - if (($this->query[$i - 1] != '\\') && ($this->query[$i] === '"')) { + if ($this->query[$i] === '"') { $this->status = 0; } $this->current .= $this->query[$i]; |