Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix variable $sql is null after preg_replace #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion library/Zend/Db/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ protected function _stripQuoted($sql)
// values and delimited identifiers stripped out
// remove "foo\"bar"
$sql = preg_replace("/\"(\\\\\"|[^\"])*\"/Us", '', $sql);

if ($sql === null) {
// this preg_replace call can return NULL in case of error (PREG_BACKTRACK_LIMIT_ERROR).
// In this case the result of this method will be an empty string.
return '';
}
// get the character for delimited id quotes,
// this is usually " but in MySQL is `
$d = $this->_adapter->quoteIdentifier('a');
Expand All @@ -220,6 +224,11 @@ protected function _stripQuoted($sql)
$de = preg_quote($de);
// Note: $de and $d where never used..., now they are:
$sql = preg_replace("/$d($de|\\\\{2}|[^$d])*$d/Us", '', $sql);
if ($sql === null) {
// this preg_replace call can return NULL in case of error (PREG_BACKTRACK_LIMIT_ERROR).
// In this case the result of this method will be an empty string.
return '';
}
return $sql;
}

Expand Down