Skip to content

Commit 9a49aa1

Browse files
Stripped null bytes from strings and filter conditions (OpenMage#1430)
1 parent d033c75 commit 9a49aa1

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

app/code/core/Mage/Core/Model/Resource/Abstract.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,8 @@ protected function _prepareDataForTable(Varien_Object $object, $table)
230230
*/
231231
protected function _prepareTableValueForSave($value, $type)
232232
{
233-
$type = strtolower($type);
234233
if ($type == 'decimal' || $type == 'numeric' || $type == 'float') {
235-
$value = Mage::app()->getLocale()->getNumber($value);
234+
return Mage::app()->getLocale()->getNumber($value);
236235
}
237236
return $value;
238237
}

lib/Varien/Db/Adapter/Pdo/Mysql.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3008,8 +3008,8 @@ public function prepareSqlCondition($fieldName, $condition)
30083008
*/
30093009
protected function _prepareQuotedSqlCondition($text, $value, $fieldName)
30103010
{
3011-
$text = str_replace('{{fieldName}}', $fieldName, $text);
3012-
return $this->quoteInto($text, $value);
3011+
$sql = $this->quoteInto($text, str_replace("\0", '', $value));
3012+
return str_replace('{{fieldName}}', $fieldName, $sql);
30133013
}
30143014

30153015
/**
@@ -3023,7 +3023,7 @@ protected function _prepareQuotedSqlCondition($text, $value, $fieldName)
30233023
*/
30243024
protected function _transformStringSqlCondition($conditionKey, $value)
30253025
{
3026-
$value = (string) $value;
3026+
$value = str_replace("\0", '', (string) $value);
30273027
if ($value == '') {
30283028
return ($conditionKey == 'seq') ? 'null' : 'notnull';
30293029
} else {
@@ -3098,7 +3098,7 @@ public function prepareColumnValue(array $column, $value)
30983098
case 'mediumtext':
30993099
case 'text':
31003100
case 'longtext':
3101-
$value = (string)$value;
3101+
$value = str_replace("\0", '', (string)$value);
31023102
if ($column['NULLABLE'] && $value == '') {
31033103
$value = null;
31043104
}

0 commit comments

Comments
 (0)