Fixes #3442, Sanitize escape NULL becomes "UL"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5885 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-10-24 11:31:32 +00:00
parent 304bc01a9d
commit 31243741f9
2 changed files with 11 additions and 9 deletions

View file

@ -72,7 +72,7 @@ class Sanitize{
*/
function escape($string, $connection = 'default') {
$db =& ConnectionManager::getDataSource($connection);
if (is_numeric($string)) {
if (is_numeric($string) || $string === null) {
return $string;
}
$string = substr($db->value($string), 1);

View file

@ -50,6 +50,15 @@ class SanitizeTest extends UnitTestCase {
$resultNumeric = Sanitize::escape('#1234.23', 'default');
$this->assertEqual($resultNumeric, '#1234.23');
$resultNull = Sanitize::escape(null, 'default');
$this->assertEqual($resultNull, null);
$resultNull = Sanitize::escape(false, 'default');
$this->assertEqual($resultNull, false);
$resultNull = Sanitize::escape(true, 'default');
$this->assertEqual($resultNull, true);
}
function testClean() {
@ -77,7 +86,7 @@ class SanitizeTest extends UnitTestCase {
$expected = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line';
$result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'carriage' => false));
$this->assertEqual($result, $expected);
$array = array(array('test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'));
$expected = array(array('test & "quote" 'other' ;.$ symbol.another line'));
$result = Sanitize::clean($array);
@ -87,13 +96,6 @@ class SanitizeTest extends UnitTestCase {
$expected = array(array('test & "quote" \'other\' ;.$ $ symbol.another line'));
$result = Sanitize::clean($array, array('encode' => false, 'escape' => false));
$this->assertEqual($result, $expected);
}
}
?>