File tree 2 files changed +28
-2
lines changed
2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -186,19 +186,31 @@ public function extract($end = false)
186
186
$ loopLen = $ end ? $ len : $ len - 16 ;
187
187
188
188
for (; $ i < $ loopLen ; ++$ i ) {
189
+ /**
190
+ * Handling backslash.
191
+ *
192
+ * Even if the next character is a special character that should be
193
+ * treated differently, because of the preceding backslash, it will
194
+ * be ignored.
195
+ */
196
+ if ($ this ->query [$ i ] === '\\' ) {
197
+ $ this ->current .= $ this ->query [$ i ] . $ this ->query [++$ i ];
198
+ continue ;
199
+ }
200
+
189
201
/*
190
202
* Handling special parses statuses.
191
203
*/
192
204
if ($ this ->status === static ::STATUS_STRING_SINGLE_QUOTES ) {
193
205
// Single-quoted strings like 'foo'.
194
- if (( $ this ->query [$ i - 1 ] != '\\' ) && ( $ this -> query [ $ i ] === '\'' ) ) {
206
+ if ($ this ->query [$ i] === '\'' ) {
195
207
$ this ->status = 0 ;
196
208
}
197
209
$ this ->current .= $ this ->query [$ i ];
198
210
continue ;
199
211
} elseif ($ this ->status === static ::STATUS_STRING_DOUBLE_QUOTES ) {
200
212
// Double-quoted strings like "bar".
201
- if (( $ this ->query [$ i - 1 ] != '\\' ) && ( $ this -> query [ $ i ] === '" ' ) ) {
213
+ if ($ this ->query [$ i] === '" ' ) {
202
214
$ this ->status = 0 ;
203
215
}
204
216
$ this ->current .= $ this ->query [$ i ];
Original file line number Diff line number Diff line change @@ -100,6 +100,20 @@ public function testExtractProvider()
100
100
101
101
return array (
102
102
103
+ array (
104
+ 'SELECT """"""""; ' .
105
+ 'SELECT """ \\\\""" ' ,
106
+ 8 ,
107
+ array (
108
+ 'parse_delimiter ' => true ,
109
+ 'add_delimiter ' => true ,
110
+ ),
111
+ array (
112
+ 'SELECT """"""""; ' ,
113
+ 'SELECT """ \\\\""" '
114
+ )
115
+ ),
116
+
103
117
array (
104
118
'DELIMITER A_VERY_LONG_DEL ' . "\n" .
105
119
'SELECT 1 A_VERY_LONG_DEL ' . "\n" .
You can’t perform that action at this time.
0 commit comments