Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libraries/src/Filter/OutputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public static function stringURLSafe($string, $language = '')
// Trim white spaces at beginning and end of alias and make lowercase
$str = trim(StringHelper::strtolower($str));

// Remove any apostrophe. We do it here to ensure it is not replaced by a '-'
$str = str_replace("'", '', $str);

// Remove any duplicate whitespace, and ensure all characters are alphanumeric
$str = preg_replace('/(\s|[^A-Za-z0-9\-])+/', '-', $str);

Expand Down
6 changes: 6 additions & 0 deletions tests/Unit/Libraries/Cms/Filter/OutputFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public function testStringURLSafe()
OutputFilter::stringURLSafe('`1234567890-=~!@#$%^&*()_+ qwertyuiop[]\QWERTYUIOP{}|asdfghjkl;\'ASDFGHJKL:"zxcvbnm,./ZXCVBNM<>?'),
'Should clean keyboard string down to ASCII-7'
);

$this->assertEquals(
'joomlas-version',
OutputFilter::stringURLSafe('joomla\'s version'),
'Should remove apostrophe from the string'
);
}

/**
Expand Down