diff options
-rw-r--r-- | engine/lib/output.php | 10 | ||||
-rw-r--r-- | engine/tests/regression/trac_bugs.php | 18 |
2 files changed, 25 insertions, 3 deletions
diff --git a/engine/lib/output.php b/engine/lib/output.php index b96cf354c..b1245a924 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -310,15 +310,19 @@ function elgg_get_friendly_title($title) { return $result; } + // @todo not using this because of locale concerns //$title = iconv('UTF-8', 'ASCII//TRANSLIT', $title); + // @todo this uses a utf8 character class. can use if + // we want to support utf8 in the url. + //$title = preg_replace('/[^\p{L}\- ]/u', '', $title); + // use A-Za-z0-9_ instead of \w because \w is locale sensitive - $title = preg_replace("/[^A-Za-z0-9_ ]/", "", $title); - $title = preg_replace("/[^\w ]/", "", $title); + $title = preg_replace("/[^A-Za-z0-9_\- ]/", "", $title); $title = str_replace(" ", "-", $title); $title = str_replace("--", "-", $title); $title = trim($title); - $title = strtolower($title); + $title = elgg_strtolower($title); return $title; } diff --git a/engine/tests/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php index 99cf81774..26a45ab6a 100644 --- a/engine/tests/regression/trac_bugs.php +++ b/engine/tests/regression/trac_bugs.php @@ -199,4 +199,22 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest { $this->assertFalse($result); $this->assertEqual(array(), $DB_DELAYED_QUERIES); } + + /** + * http://trac.elgg.org/ticket/3210 - Don't remove -s in friendly titles + * @todo: http://trac.elgg.org/ticket/2276 - improve char encoding + */ + public function test_friendly_title() { + $cases = array( + 'Simple Test' => 'simple-test', + 'Test top-level page' => 'test-top-level-page', +// 'éclair' => 'éclair', +// 'English, Español, and 日本語' => 'english-español-and-日本語' + ); + + foreach ($cases as $case => $expected) { + $friendly_title = elgg_get_friendly_title($case); + $this->assertIdentical($expected, $friendly_title); + } + } } |