summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRaghuram <raghuram.vadapalli@research.iiit.ac.in>2017-04-05 22:00:53 +0530
committerRaghuram <raghuram.vadapalli@research.iiit.ac.in>2017-04-05 22:02:55 +0530
commite52cabfaa0bd7d51fa3545c45f8d7fd804d379ba (patch)
tree8acd43fa8b0079cc753e4c7effbccb6370d5e7db /src
parent6305be565414a4471133c251791edc4b31e97a4f (diff)
downloadsql-parser-e52cabfaa0bd7d51fa3545c45f8d7fd804d379ba.zip
sql-parser-e52cabfaa0bd7d51fa3545c45f8d7fd804d379ba.tar.gz
sql-parser-e52cabfaa0bd7d51fa3545c45f8d7fd804d379ba.tar.bz2
Fixes striping of inline comments #11717
Signed-off-by: Raghuram Vadapalli <raghuram.vadapalli@research.iiit.ac.in>
Diffstat (limited to 'src')
-rw-r--r--src/Utils/BufferedQuery.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php
index acd11e0..b333fa3 100644
--- a/src/Utils/BufferedQuery.php
+++ b/src/Utils/BufferedQuery.php
@@ -15,8 +15,6 @@ use PhpMyAdmin\SqlParser\Context;
* that are being buffered. After each statement has been extracted, a lexer or
* a parser may be used.
*
- * All comments are skipped, with one exception: MySQL commands inside `/*!`.
- *
* @category Lexer
*
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
@@ -228,12 +226,14 @@ class BufferedQuery
if ($this->query[$i] === "\n") {
$this->status = 0;
}
+ $this->current .= $this->query[$i];
continue;
} elseif ($this->status === static::STATUS_COMMENT_C) {
// C-like comments end in */.
if (($this->query[$i - 1] === '*') && ($this->query[$i] === '/')) {
$this->status = 0;
}
+ $this->current .= $this->query[$i];
continue;
}
@@ -259,6 +259,7 @@ class BufferedQuery
*/
if ($this->query[$i] === '#') {
$this->status = static::STATUS_COMMENT_BASH;
+ $this->current .= $this->query[$i];
continue;
} elseif (($i + 2 < $len)
&& ($this->query[$i] === '-')
@@ -266,6 +267,7 @@ class BufferedQuery
&& (Context::isWhitespace($this->query[$i + 2]))
) {
$this->status = static::STATUS_COMMENT_SQL;
+ $this->current .= $this->query[$i];
continue;
} elseif (($i + 2 < $len)
&& ($this->query[$i] === '/')
@@ -273,6 +275,7 @@ class BufferedQuery
&& ($this->query[$i + 2] !== '!')
) {
$this->status = static::STATUS_COMMENT_C;
+ $this->current .= $this->query[$i];
continue;
}
@@ -299,7 +302,6 @@ class BufferedQuery
&& (($this->query[$i + 7] === 'E') || ($this->query[$i + 7] === 'e'))
&& (($this->query[$i + 8] === 'R') || ($this->query[$i + 8] === 'r'))
&& (Context::isWhitespace($this->query[$i + 9]))
- && (trim($this->current) === '')
) {
// Saving the current index to be able to revert any parsing
// done in this block.