Fixing issues with Sanitize::stripWhitespace() and utf8 characters.

Fixes #1862
This commit is contained in:
Mark Story 2011-07-31 15:44:10 -04:00
parent 762fcf2c42
commit 416e527cbc
2 changed files with 6 additions and 1 deletions

View file

@ -130,7 +130,7 @@ class Sanitize {
*/
function stripWhitespace($str) {
$r = preg_replace('/[\n\r\t]+/', '', $str);
return preg_replace('/\s{2,}/', ' ', $r);
return preg_replace('/\s{2,}/u', ' ', $r);
}
/**

View file

@ -261,6 +261,11 @@ class SanitizeTest extends CakeTestCase {
$expected = "This sentence has lots of whitespace that needs to be trimmed.";
$result = Sanitize::stripWhitespace($string);
$this->assertEqual($result, $expected);
$text = 'I love ßá†ö√ letters.';
$result = Sanitize::stripWhitespace($text);
$expected = 'I love ßá†ö√ letters.';
$this->assertEqual($result, $expected);
}
/**