From 97fac72366a5bbe88b47a24c63603a2058c78ff7 Mon Sep 17 00:00:00 2001 From: infograf768 Date: Sat, 31 Dec 2011 10:57:11 +0100 Subject: [PATCH 1/5] Useless replacement for alias. http://groups.google.com/group/joomlabugsquad/t/12ca167dcaa6bacd?hl=en --- libraries/joomla/filter/output.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/joomla/filter/output.php b/libraries/joomla/filter/output.php index 6894b27e37..71184502b7 100644 --- a/libraries/joomla/filter/output.php +++ b/libraries/joomla/filter/output.php @@ -91,9 +91,6 @@ public static function stringURLSafe($string) $lang = JFactory::getLanguage(); $str = $lang->transliterate($str); - // Convert certain symbols to letter representation - $str = str_replace(array('&', '"', '<', '>'), array('a', 'q', 'l', 'g'), $str); - // Lowercase and trim $str = trim(strtolower($str)); From 9d341d5436ee800dac70f28b6dfd76f0d10920ce Mon Sep 17 00:00:00 2001 From: infograf768 Date: Sun, 1 Jan 2012 19:30:03 +0100 Subject: [PATCH 2/5] Update libraries/joomla/filter/output.php --- libraries/joomla/filter/output.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/joomla/filter/output.php b/libraries/joomla/filter/output.php index 71184502b7..f0822fa33f 100644 --- a/libraries/joomla/filter/output.php +++ b/libraries/joomla/filter/output.php @@ -90,12 +90,16 @@ public static function stringURLSafe($string) $lang = JFactory::getLanguage(); $str = $lang->transliterate($str); + + // Convert certain symbols to spaces + $str = str_replace(array('&', '<', '>'), array(' ', ' ', ' '), $str); - // Lowercase and trim - $str = trim(strtolower($str)); + // Trim white spaces at beginning and end of alias and make lowercase + $str = trim(JString::strtolower($str)); // Remove any duplicate whitespace, and ensure all characters are alphanumeric $str = preg_replace(array('/\s+/', '/[^A-Za-z0-9\-]/'), array('-', ''), $str); + return $str; } @@ -120,7 +124,7 @@ public static function stringURLUnicodeSlug($string) $str = str_replace('-', ' ', $str); // Replace forbidden characters by whitespaces - $str = preg_replace('#[:\#\*"@+=;!&\.%()\]\/\'\\\\|\[]#', "\x20", $str); + $str = preg_replace('#[:\#\*"@+=;!><&\.%()\]\/\'\\\\|\[]#', "\x20", $str); // Delete all '?' $str = str_replace('?', '', $str); From d00ddb14507ab93517a7f42ddd4226e42af85e08 Mon Sep 17 00:00:00 2001 From: infograf768 Date: Mon, 2 Jan 2012 07:38:54 +0100 Subject: [PATCH 3/5] Update libraries/joomla/filter/output.php --- libraries/joomla/filter/output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/joomla/filter/output.php b/libraries/joomla/filter/output.php index f0822fa33f..fedd6b6412 100644 --- a/libraries/joomla/filter/output.php +++ b/libraries/joomla/filter/output.php @@ -92,7 +92,7 @@ public static function stringURLSafe($string) $str = $lang->transliterate($str); // Convert certain symbols to spaces - $str = str_replace(array('&', '<', '>'), array(' ', ' ', ' '), $str); + $str = str_replace(array('&', '"', '<', '>'), array(' ', ' ', ' ', ' '), $str); // Trim white spaces at beginning and end of alias and make lowercase $str = trim(JString::strtolower($str)); From e498e66007c0c007322fe234a54cc5c8ac79d275 Mon Sep 17 00:00:00 2001 From: infograf768 Date: Tue, 3 Jan 2012 06:26:24 +0100 Subject: [PATCH 4/5] Update libraries/joomla/filter/output.php --- libraries/joomla/filter/output.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libraries/joomla/filter/output.php b/libraries/joomla/filter/output.php index fedd6b6412..500814bda4 100644 --- a/libraries/joomla/filter/output.php +++ b/libraries/joomla/filter/output.php @@ -85,22 +85,21 @@ public static function linkXHTMLSafe($input) */ public static function stringURLSafe($string) { - //remove any '-' from the string since they will be used as concatenaters + // remove any '-' from the string since they will be used as concatenaters $str = str_replace('-', ' ', $string); $lang = JFactory::getLanguage(); $str = $lang->transliterate($str); - - // Convert certain symbols to spaces - $str = str_replace(array('&', '"', '<', '>'), array(' ', ' ', ' ', ' '), $str); // Trim white spaces at beginning and end of alias and make lowercase $str = trim(JString::strtolower($str)); // Remove any duplicate whitespace, and ensure all characters are alphanumeric - $str = preg_replace(array('/\s+/', '/[^A-Za-z0-9\-]/'), array('-', ''), $str); + $str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-', $str); + + // Trim dashes at beginning and end of alias + $str = trim($str, '-'); - return $str; } From e5c7d1dd5eaf30bc695f24f037fad50cff0e3479 Mon Sep 17 00:00:00 2001 From: infograf768 Date: Tue, 3 Jan 2012 06:30:26 +0100 Subject: [PATCH 5/5] Update tests/suite/joomla/filter/JFilterOutputTest.php --- tests/suite/joomla/filter/JFilterOutputTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suite/joomla/filter/JFilterOutputTest.php b/tests/suite/joomla/filter/JFilterOutputTest.php index 759a943059..3847b3adde 100644 --- a/tests/suite/joomla/filter/JFilterOutputTest.php +++ b/tests/suite/joomla/filter/JFilterOutputTest.php @@ -124,7 +124,7 @@ public function testLinkXHTMLSafe() public function testStringURLSafe() { $this->assertEquals( - '1234567890-a-qwertyuiopqwertyuiopasdfghjklasdfghjklqzxcvbnmzxcvbnmlg', + '1234567890-qwertyuiop-qwertyuiop-asdfghjkl-asdfghjkl-zxcvbnm-zxcvbnm', $this->object->stringURLSafe('`1234567890-=~!@#$%^&*()_+ qwertyuiop[]\QWERTYUIOP{}|asdfghjkl;\'ASDFGHJKL:"zxcvbnm,./ZXCVBNM<>?'), 'Should clean keyboard string down to ASCII-7' );