mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing issues with Sanitize::stripWhitespace() and utf8 characters.
Fixes #1862
This commit is contained in:
parent
762fcf2c42
commit
416e527cbc
2 changed files with 6 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue