From fe4a3e8727164ceded739387c16f49bd2987431c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 2 Mar 2016 14:04:00 +0100 Subject: [PATCH] Fixed processing of queries with escaped quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Imported SQL parser d2e37de1dbec251556f35712bddcd61d24baaee6 Fixes #12054 Signed-off-by: Michal Čihař --- ChangeLog | 1 + libraries/sql-parser/src/Utils/BufferedQuery.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ffb8e0ae9b..11356157b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -49,6 +49,7 @@ phpMyAdmin - ChangeLog - issue Fix SQL syntax highlighting in database search page - issue #12056 Fix error when we can not generate random string - issue #12055 Fixed PHP syntax error in templates +- issue #12054 Fixed processing of queries with escaped quotes 4.5.5.1 (2016-02-29) - issue #11971 CREATE UNIQUE INDEX index type is not recognized by parser. diff --git a/libraries/sql-parser/src/Utils/BufferedQuery.php b/libraries/sql-parser/src/Utils/BufferedQuery.php index 1aaa9d7910..500862a19b 100644 --- a/libraries/sql-parser/src/Utils/BufferedQuery.php +++ b/libraries/sql-parser/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];