summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Utils/BufferedQuery.php4
-rw-r--r--tests/Utils/BufferedQueryTest.php13
2 files changed, 15 insertions, 2 deletions
diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php
index 1aaa9d7..500862a 100644
--- a/src/Utils/BufferedQuery.php
+++ b/src/Utils/BufferedQuery.php
@@ -209,14 +209,14 @@ class BufferedQuery
*/
if ($this->status === static::STATUS_STRING_SINGLE_QUOTES) {
// Single-quoted strings like 'foo'.
- if ($this->query[$i] === '\'') {
+ if ($this->query[$i] === '\'' && $this->query[$i - 1] !== '\\') {
$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] === '"') {
+ if ($this->query[$i] === '"' && $this->query[$i - 1] !== '\\') {
$this->status = 0;
}
$this->current .= $this->query[$i];
diff --git a/tests/Utils/BufferedQueryTest.php b/tests/Utils/BufferedQueryTest.php
index a6bf3ed..ae406a4 100644
--- a/tests/Utils/BufferedQueryTest.php
+++ b/tests/Utils/BufferedQueryTest.php
@@ -101,6 +101,19 @@ class BufferedQueryTest extends TestCase
return array(
array(
+ "SELECT '\'';\nSELECT '\'';",
+ 8,
+ array(
+ 'parse_delimiter' => true,
+ 'add_delimiter' => true,
+ ),
+ array(
+ "SELECT '\'';",
+ "SELECT '\'';",
+ )
+ ),
+
+ array(
'SELECT """""""";' .
'SELECT """\\\\"""',
8,