Skip to content
Permalink
Browse files

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

Fixes #1862
  • Loading branch information...
markstory committed Jul 31, 2011
1 parent 762fcf2 commit 416e527cbc31faa347616e6617789963a9547fbc
Showing with 6 additions and 1 deletion.
  1. +1 −1 cake/libs/sanitize.php
  2. +5 −0 cake/tests/cases/libs/sanitize.test.php
@@ -130,7 +130,7 @@ function html($string, $options = array()) {
*/
function stripWhitespace($str) {
$r = preg_replace('/[\n\r\t]+/', '', $str);
return preg_replace('/\s{2,}/', ' ', $r);
return preg_replace('/\s{2,}/u', ' ', $r);
}
/**
@@ -261,6 +261,11 @@ function testStripWhitespace() {
$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);
}
/**

0 comments on commit 416e527

Please sign in to comment.
You can’t perform that action at this time.