Replace non-breaking spaces with Inflector::slug().

Fixes #2363
This commit is contained in:
mark_story 2013-11-22 10:13:10 -05:00
parent a4460ff228
commit 37e387fed2
2 changed files with 5 additions and 2 deletions

View file

@ -252,6 +252,9 @@ class InflectorTest extends CakeTestCase {
$result = Inflector::slug('posts/view/한국어/page:1/sort:asc');
$expected = 'posts_view_한국어_page_1_sort_asc';
$this->assertEquals($expected, $result);
$result = Inflector::slug("non\xc2\xa0breaking\xc2\xa0space");
$this->assertEquals('non_breaking_space', $result);
}
/**

View file

@ -542,8 +542,8 @@ class Inflector {
$quotedReplacement = preg_quote($replacement, '/');
$merge = array(
'/[^\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ',
'/\\s+/' => $replacement,
'/[^\s\p{Zs}\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ',
'/[\s\p{Zs}]+/mu' => $replacement,
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
);