Permalink
Browse files

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

Fixes #2363
  • Loading branch information...
1 parent a4460ff commit 37e387fed2790a945e35b6119cbf0d5c8b45456b @markstory markstory committed Nov 22, 2013
Showing with 5 additions and 2 deletions.
  1. +3 −0 lib/Cake/Test/Case/Utility/InflectorTest.php
  2. +2 −2 lib/Cake/Utility/Inflector.php
@@ -252,6 +252,9 @@ public function testInflectorSlug() {
$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);
}
/**
@@ -542,8 +542,8 @@ public static function slug($string, $replacement = '_') {
$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) => '',
);

0 comments on commit 37e387f

Please sign in to comment.