diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index c894bc931..8164eb20f 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -438,6 +438,7 @@ class Inflector extends Object { '/ß/' => 'ss', '/[^\w\s]/' => ' ', '/\\s+/' => $replacement, + String::insert('/^[:replacement]+|[:replacement]+$/', array('replacement' => preg_quote($replacement, '/'))) => '', ); $string = preg_replace(array_keys($map), array_values($map), $string); return $string; diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php index 84b751aa9..12c7c309b 100644 --- a/cake/tests/cases/libs/inflector.test.php +++ b/cake/tests/cases/libs/inflector.test.php @@ -147,6 +147,18 @@ class InflectorTest extends UnitTestCase { $result = Inflector::slug('La langue française est un attribut de souveraineté en France', '-'); $expected = 'La-langue-francaise-est-un-attribut-de-souverainete-en-France'; $this->assertEqual($result, $expected); + + $result = Inflector::slug('!@$#exciting stuff! - what !@-# was that?', '-'); + $expected = 'exciting-stuff-what-was-that'; + $this->assertEqual($result, $expected); + + $result = Inflector::slug('20% of profits went to me!', '-'); + $expected = '20-of-profits-went-to-me'; + $this->assertEqual($result, $expected); + + $result = Inflector::slug('#this melts your face1#2#3', '-'); + $expected = 'this-melts-your-face1-2-3'; + $this->assertEqual($result, $expected); } function testVariableNaming() {