diff --git a/model/URLSegmentFilter.php b/model/URLSegmentFilter.php index 505709b6e..13d41c498 100644 --- a/model/URLSegmentFilter.php +++ b/model/URLSegmentFilter.php @@ -32,7 +32,7 @@ class URLSegmentFilter extends Object { '/\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 in case multibyte is allowed (and ASCII chars aren't removed) + '/[\/\?=#]+/u' => '-', // remove forward slashes, question marks, equal signs and hashes 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 diff --git a/tests/model/URLSegmentFilterTest.php b/tests/model/URLSegmentFilterTest.php index 433e73469..a15b6f776 100644 --- a/tests/model/URLSegmentFilterTest.php +++ b/tests/model/URLSegmentFilterTest.php @@ -95,5 +95,11 @@ class URLSegmentFilterTest extends SapphireTest { $filter = new URLSegmentFilter(); $this->assertEquals('url-has-trailing-dashes', $filter->filter('url-has-trailing-dashes--')); } + + public function testRemovesBadCharactersWithMultibyteAllowed() { + $filter = new URLSegmentFilter(); + $filter->setAllowMultibyte(true); + $this->assertEquals('url-with-bad-characters', $filter->filter('url?-with/-bad#-characters=')); + } }