URLSegmentFilter: Remove : characters from url segments when multibyte characters are allowed.

This commit is contained in:
Jarkko Linnanvirta 2019-06-02 11:43:51 +03:00
parent 0520d77461
commit 9184056b5e
2 changed files with 2 additions and 2 deletions

View File

@ -36,7 +36,7 @@ class URLSegmentFilter
'/\s|\+/u' => '-', // remove whitespace/plus
'/[_.]+/u' => '-', // underscores and dots to dashes
'/[^A-Za-z0-9\-]+/u' => '', // remove non-ASCII chars, only allow alphanumeric and dashes
'/[\/\?=#]+/u' => '-', // remove forward slashes, question marks, equal signs and hashes in case multibyte is allowed (and non-ASCII chars aren't removed)
'/[\/\?=#:]+/u' => '-', // remove forward slashes, question marks, equal signs, hashes and colons in case multibyte is allowed (and non-ASCII chars aren't removed)
'/[\-]{2,}/u' => '-', // remove duplicate dashes
'/^[\-]+/u' => '', // Remove all leading dashes
'/[\-]+$/u' => '' // Remove all trailing dashes

View File

@ -113,6 +113,6 @@ class URLSegmentFilterTest extends SapphireTest
{
$filter = new URLSegmentFilter();
$filter->setAllowMultibyte(true);
$this->assertEquals('url-with-bad-characters', $filter->filter('url?-with/-bad#-characters='));
$this->assertEquals('url-with-some-bad-characters', $filter->filter('url?-with/-some:-bad#-characters='));
}
}