Permalink
Browse files

Modified Inflector::slug to not drop multibyte characters. Fixes #6104.

  • Loading branch information...
1 parent 986af28 commit 659c1a65bc63482812d716c96988c58009672997 @jperras jperras committed Jul 25, 2009
Showing with 6 additions and 1 deletion.
  1. +2 −1 cake/libs/inflector.php
  2. +4 −0 cake/tests/cases/libs/inflector.test.php
@@ -447,10 +447,11 @@ function slug($string, $replacement = '_', $map = array()) {
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/ß/' => 'ss',
- '/[^\w\s]/' => ' ',
+ '/[^\w\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ',
'/\\s+/' => $replacement,
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
);
+
$map = array_merge($default, $map);
return preg_replace(array_keys($map), array_values($map), $string);
}
@@ -200,6 +200,10 @@ function testInflectorSlug() {
$result = Inflector::slug('#this melts your face1#2#3', '-');
$expected = 'this-melts-your-face1-2-3';
$this->assertEqual($result, $expected);
+
+ $result = Inflector::slug('controller/action/りんご/1');
+ $expected = 'controller_action_りんご_1';
+ $this->assertEqual($result, $expected);
}
/**
* testInflectorSlugWithMap method

0 comments on commit 659c1a6

Please sign in to comment.