This repository was archived by the owner on May 16, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -191,13 +191,13 @@ protected function _stripQuoted($sql)
191
191
if (!empty ($ q )) {
192
192
$ escapeChar = preg_quote ($ escapeChar );
193
193
// this segfaults only after 65,000 characters instead of 9,000
194
- $ sql = preg_replace ("/ $ q([^ $ q {$ escapeChar }]*|( $ qe)*)* $ q/s " , '' , $ sql );
194
+ $ sql = preg_replace ("/ $ q(?: [^ $ q {$ escapeChar }]*|(?: $ qe)*)* $ q/s " , '' , $ sql );
195
195
}
196
196
197
197
// get a version of the SQL statement with all quoted
198
198
// values and delimited identifiers stripped out
199
199
// remove "foo\"bar"
200
- $ sql = preg_replace ("/ \"( \\\\\" |[^ \" ])* \"/Us " , '' , $ sql );
200
+ $ sql = preg_replace ("/ \".*(?:(?! \\\\).) \"/Us " , '' , $ sql );
201
201
202
202
// get the character for delimited id quotes,
203
203
// this is usually " but in MySQL is `
@@ -209,7 +209,7 @@ protected function _stripQuoted($sql)
209
209
$ de = substr ($ de , 1 , 2 );
210
210
$ de = preg_quote ($ de );
211
211
// Note: $de and $d where never used..., now they are:
212
- $ sql = preg_replace ("/ $ d( $ de| \\\\{2}|[^ $ d])* $ d/Us " , '' , $ sql );
212
+ $ sql = preg_replace ("/ $ d(?: $ de| \\\\{2}|[^ $ d])* $ d/Us " , '' , $ sql );
213
213
return $ sql ;
214
214
}
215
215
Original file line number Diff line number Diff line change @@ -149,6 +149,22 @@ public function testStripQuoted()
149
149
$ this ->assertSame ($ out , $ actual , $ count . ' - unexpected output ' );
150
150
}
151
151
}
152
+
153
+ public function testStripQuotedForLongQuery ()
154
+ {
155
+ $ statementClass = 'Zend_Db_Statement_ ' . $ this ->getDriver ();
156
+
157
+ $ table = $ this ->_db ->quoteIdentifier ('zfproducts ' );
158
+ $ column = $ this ->_db ->quoteIdentifier ('product_name ' );
159
+
160
+ $ sql = 'SELECT * FROM `zfproducts` WHERE `product_name` = "%s" ' ;
161
+
162
+ $ columnContent = str_repeat ('a ' , 15000 ) . '\\" ' . str_repeat ('b ' , 15000 );
163
+ $ sql = sprintf ($ sql , $ columnContent );
164
+
165
+ $ stmt = new $ statementClass ($ this ->_db , $ sql );
166
+ $ this ->assertNotNull ($ stmt ->getDriverStatement ());
167
+ }
152
168
153
169
public function testStatementRowCount ()
154
170
{
You can’t perform that action at this time.
0 commit comments