Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 659c1a65bc63482812d716c96988c58009672997 1 parent 986af28
Joel Perras authored July 25, 2009
3  cake/libs/inflector.php
@@ -447,10 +447,11 @@ function slug($string, $replacement = '_', $map = array()) {
447 447
 			'/Ü/' => 'Ue',
448 448
 			'/Ö/' => 'Oe',
449 449
 			'/ß/' => 'ss',
450  
-			'/[^\w\s]/' => ' ',
  450
+			'/[^\w\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ',
451 451
 			'/\\s+/' => $replacement,
452 452
 			sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
453 453
 		);
  454
+
454 455
 		$map = array_merge($default, $map);
455 456
 		return preg_replace(array_keys($map), array_values($map), $string);
456 457
 	}
4  cake/tests/cases/libs/inflector.test.php
@@ -200,6 +200,10 @@ function testInflectorSlug() {
200 200
 		$result = Inflector::slug('#this melts your face1#2#3', '-');
201 201
 		$expected = 'this-melts-your-face1-2-3';
202 202
 		$this->assertEqual($result, $expected);
  203
+
  204
+		$result = Inflector::slug('controller/action/りんご/1');
  205
+		$expected = 'controller_action_りんご_1';
  206
+		$this->assertEqual($result, $expected);
203 207
 	}
204 208
 /**
205 209
  * testInflectorSlugWithMap method

0 notes on commit 659c1a6

Please sign in to comment.
Something went wrong with that request. Please try again.