Skip to content

Commit a93a220

Browse files
committed
handle single and double quoted strings
1 parent d2cee4c commit a93a220

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

lib_sql_parser.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,27 @@ public function lex($sql){
9595
# <national character string literal>
9696
# <bit string literal>
9797
# <hex string literal>
98+
9899
# <character string literal>
100+
if ($sql[$pos] == "'" || $sql[$pos] == '"'){
101+
$c = $pos+1;
102+
$q = $sql[$pos];
103+
while ($c < strlen($sql)){
104+
if ($sql[$c] == '\\'){
105+
$c += 2;
106+
continue;
107+
}
108+
if ($sql[$c] == $q){
109+
$slen = $c + 1 - $pos;
110+
$tokens[] = substr($sql, $pos, $slen);
111+
$pos += $slen;
112+
break;
113+
}
114+
$c++;
115+
}
116+
continue;
117+
}
118+
99119
# <date string>
100120
# <time string>
101121
# <timestamp string>

0 commit comments

Comments
 (0)