Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
Merge pull request #685 from infograf768/patch-2
Browse files Browse the repository at this point in the history
Useless replacement for some alias glyphs.
  • Loading branch information
chdemko committed Jan 3, 2012
2 parents 5573bd4 + e5c7d1d commit 64520f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions libraries/joomla/filter/output.php
Expand Up @@ -85,21 +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 letter representation
$str = str_replace(array('&', '"', '<', '>'), array('a', 'q', 'l', 'g'), $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);

$str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-', $str);

// Trim dashes at beginning and end of alias
$str = trim($str, '-');

return $str;
}

Expand All @@ -123,7 +123,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);
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/joomla/filter/JFilterOutputTest.php
Expand Up @@ -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'
);
Expand Down

0 comments on commit 64520f4

Please sign in to comment.