updating Sanitize::clean() odd spaces, fixes #3576

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6046 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-11-22 17:05:40 +00:00
parent 10f259c95b
commit eba8f6770b
2 changed files with 15 additions and 9 deletions

View file

@ -204,30 +204,30 @@ class Sanitize {
return $data;
} else {
if ($options['odd_spaces']) {
$val = str_replace(chr(0xCA), '', str_replace(' ', ' ', $data));
$data = str_replace(chr(0xCA), '', str_replace(' ', ' ', $data));
}
if ($options['encode']) {
$val = Sanitize::html($val);
$data = Sanitize::html($data);
}
if ($options['dollar']) {
$val = str_replace("\\\$", "$", $val);
$data = str_replace("\\\$", "$", $data);
}
if ($options['carriage']) {
$val = str_replace("\r", "", $val);
$data = str_replace("\r", "", $data);
}
$val = str_replace("'", "'", str_replace("!", "!", $val));
$data = str_replace("'", "'", str_replace("!", "!", $data));
if ($options['unicode']) {
$val = preg_replace("/&#([0-9]+);/s", "&#\\1;", $val);
$data = preg_replace("/&#([0-9]+);/s", "&#\\1;", $data);
}
if ($options['escape']) {
$val = Sanitize::escape($val, $options['connection']);
$data = Sanitize::escape($data, $options['connection']);
}
if ($options['backslash']) {
$val = preg_replace("/\\\(?!&#|\?#)/", "\\", $val);
$data = preg_replace("/\\\(?!&#|\?#)/", "\\", $data);
}
return $val;
return $data;
}
}
/**

View file

@ -101,6 +101,12 @@ class SanitizeTest extends CakeTestCase {
$expected = array(array('test & "quote" \'other\' ;.$ $ symbol.another line'));
$result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test_suite'));
$this->assertEqual($result, $expected);
$array = array(array('test odd '.chr(0xCA).' spaces'.chr(0xCA)));
$expected = array(array('test odd '.chr(0xCA).' spaces'.chr(0xCA)));
$result = Sanitize::clean($array, array('odd_spaces' => false, 'escape' => false, 'connection' => 'test_suite'));
$this->assertEqual($result, $expected);
}
}
?>