Skip to content

Commit

Permalink
Stripped null bytes from strings and filter conditions (#1430)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmollenhour authored Sep 12, 2022
1 parent d033c75 commit 9a49aa1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/code/core/Mage/Core/Model/Resource/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ protected function _prepareDataForTable(Varien_Object $object, $table)
*/
protected function _prepareTableValueForSave($value, $type)
{
$type = strtolower($type);
if ($type == 'decimal' || $type == 'numeric' || $type == 'float') {
$value = Mage::app()->getLocale()->getNumber($value);
return Mage::app()->getLocale()->getNumber($value);
}
return $value;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Varien/Db/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -3008,8 +3008,8 @@ public function prepareSqlCondition($fieldName, $condition)
*/
protected function _prepareQuotedSqlCondition($text, $value, $fieldName)
{
$text = str_replace('{{fieldName}}', $fieldName, $text);
return $this->quoteInto($text, $value);
$sql = $this->quoteInto($text, str_replace("\0", '', $value));
return str_replace('{{fieldName}}', $fieldName, $sql);
}

/**
Expand All @@ -3023,7 +3023,7 @@ protected function _prepareQuotedSqlCondition($text, $value, $fieldName)
*/
protected function _transformStringSqlCondition($conditionKey, $value)
{
$value = (string) $value;
$value = str_replace("\0", '', (string) $value);
if ($value == '') {
return ($conditionKey == 'seq') ? 'null' : 'notnull';
} else {
Expand Down Expand Up @@ -3098,7 +3098,7 @@ public function prepareColumnValue(array $column, $value)
case 'mediumtext':
case 'text':
case 'longtext':
$value = (string)$value;
$value = str_replace("\0", '', (string)$value);
if ($column['NULLABLE'] && $value == '') {
$value = null;
}
Expand Down

0 comments on commit 9a49aa1

Please sign in to comment.