diff -r 5e7a0fedabdf -r 877f952ae2bd web/lib/Zend/Db/Statement.php --- a/web/lib/Zend/Db/Statement.php Thu Mar 21 17:31:31 2013 +0100 +++ b/web/lib/Zend/Db/Statement.php Thu Mar 21 19:50:53 2013 +0100 @@ -15,9 +15,9 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Statement.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Statement.php 24790 2012-05-10 12:28:51Z mcleod@spaceweb.nl $ */ /** @@ -36,7 +36,7 @@ * @category Zend * @package Zend_Db * @subpackage Statement - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface @@ -176,37 +176,40 @@ */ protected function _stripQuoted($sql) { - // get the character for delimited id quotes, - // this is usually " but in MySQL is ` - $d = $this->_adapter->quoteIdentifier('a'); - $d = $d[0]; - - // get the value used as an escaped delimited id quote, - // e.g. \" or "" or \` - $de = $this->_adapter->quoteIdentifier($d); - $de = substr($de, 1, 2); - $de = str_replace('\\', '\\\\', $de); // get the character for value quoting // this should be ' $q = $this->_adapter->quote('a'); - $q = $q[0]; - + $q = $q[0]; // get the value used as an escaped quote, // e.g. \' or '' $qe = $this->_adapter->quote($q); $qe = substr($qe, 1, 2); - $qe = str_replace('\\', '\\\\', $qe); - + $qe = preg_quote($qe); + $escapeChar = substr($qe,0,1); + // remove 'foo\'bar' + if (!empty($q)) { + $escapeChar = preg_quote($escapeChar); + // this segfaults only after 65,000 characters instead of 9,000 + $sql = preg_replace("/$q([^$q{$escapeChar}]*|($qe)*)*$q/s", '', $sql); + } + // get a version of the SQL statement with all quoted // values and delimited identifiers stripped out // remove "foo\"bar" - $sql = preg_replace("/$q($qe|\\\\{2}|[^$q])*$q/", '', $sql); - // remove 'foo\'bar' - if (!empty($q)) { - $sql = preg_replace("/$q($qe|[^$q])*$q/", '', $sql); - } + $sql = preg_replace("/\"(\\\\\"|[^\"])*\"/Us", '', $sql); + // get the character for delimited id quotes, + // this is usually " but in MySQL is ` + $d = $this->_adapter->quoteIdentifier('a'); + $d = $d[0]; + // get the value used as an escaped delimited id quote, + // e.g. \" or "" or \` + $de = $this->_adapter->quoteIdentifier($d); + $de = substr($de, 1, 2); + $de = preg_quote($de); + // Note: $de and $d where never used..., now they are: + $sql = preg_replace("/$d($de|\\\\{2}|[^$d])*$d/Us", '', $sql); return $sql; }