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 1/2] 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]; From f76ddbe7ab43e96b33ab7041a4917d86dda5e987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 2 Mar 2016 14:49:40 +0100 Subject: [PATCH 2/2] Update SQL parser to ad0e75faa6f6943d013f23d0d1ca31b4781e7b79 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - issue #12041 Fixed exporting tables with fields DEFAULT and COMMENT Fixes #12041 Signed-off-by: Michal Čihař --- ChangeLog | 1 + libraries/sql-parser/src/Components/Condition.php | 1 + libraries/sql-parser/src/Components/Expression.php | 3 +++ libraries/sql-parser/src/Statements/DropStatement.php | 1 + 4 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 11356157b8..33b4d84515 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,7 @@ phpMyAdmin - ChangeLog - 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 +- issue #12041 Fixed exporting tables with fields DEFAULT and COMMENT 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/Components/Condition.php b/libraries/sql-parser/src/Components/Condition.php index e84ad864ac..65374ccbd2 100644 --- a/libraries/sql-parser/src/Components/Condition.php +++ b/libraries/sql-parser/src/Components/Condition.php @@ -38,6 +38,7 @@ class Condition extends Component * @var array */ public static $ALLOWED_KEYWORDS = array( + 'ALL' => 1, 'AND' => 1, 'BETWEEN' => 1, 'EXISTS' => 1, diff --git a/libraries/sql-parser/src/Components/Expression.php b/libraries/sql-parser/src/Components/Expression.php index 0b9f21513a..8d6471c4af 100644 --- a/libraries/sql-parser/src/Components/Expression.php +++ b/libraries/sql-parser/src/Components/Expression.php @@ -254,6 +254,9 @@ class Expression extends Component continue; } $isExpr = true; + } elseif ($brackets === 0 && count($ret->expr) > 0) { + /* End of expression */ + break; } } diff --git a/libraries/sql-parser/src/Statements/DropStatement.php b/libraries/sql-parser/src/Statements/DropStatement.php index 5110c9db16..063146e1f5 100644 --- a/libraries/sql-parser/src/Statements/DropStatement.php +++ b/libraries/sql-parser/src/Statements/DropStatement.php @@ -39,6 +39,7 @@ class DropStatement extends Statement 'SCHEMA' => 1, 'SERVER' => 1, 'TABLE' => 1, + 'VIEW' => 1, 'TABLESPACE' => 1, 'TRIGGER' => 1,