mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Remove forward slash in URLs in multibyte mode
Fixes https://github.com/silverstripe/silverstripe-cms/issues/1262
This commit is contained in:
parent
445f1d4ccb
commit
860b5dcc6e
@ -32,6 +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)
|
||||
'/[\-]{2,}/u' => '-', // remove duplicate dashes
|
||||
'/^[\-]+/u' => '', // Remove all leading dashes
|
||||
'/[\-]+$/u' => '' // Remove all trailing dashes
|
||||
|
@ -55,6 +55,15 @@ class URLSegmentFilterTest extends SapphireTest {
|
||||
);
|
||||
}
|
||||
|
||||
public function testReplacesForwardSlashesWithAllowMultiByteOption() {
|
||||
$f = new URLSegmentFilter();
|
||||
$f->setAllowMultibyte(true);
|
||||
$this->assertEquals(
|
||||
urlencode('this-that'),
|
||||
$f->filter('this/that')
|
||||
);
|
||||
}
|
||||
|
||||
public function testReplacements() {
|
||||
$f = new URLSegmentFilter();
|
||||
$this->assertEquals(
|
||||
|
Loading…
x
Reference in New Issue
Block a user