mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-10 01:03:13 +08:00
Be less restrictive on what characters are disallowed in custom slugs
This commit is contained in:
@@ -46,10 +46,10 @@ class CustomSlugValidator extends AbstractValidator
|
||||
return false;
|
||||
}
|
||||
|
||||
// URL reserved characters: https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
|
||||
$reservedChars = "!*'();:@&=+$,?%#[]";
|
||||
// URL gen-delimiter reserved characters, except `/`: https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
|
||||
$reservedChars = ':?#[]@';
|
||||
if (! $this->options->multiSegmentSlugsEnabled) {
|
||||
// Slashes should be allowed for multi-segment slugs
|
||||
// Slashes should only be allowed if multi-segment slugs are enabled
|
||||
$reservedChars .= '/';
|
||||
}
|
||||
|
||||
|
||||
@@ -59,13 +59,11 @@ class CustomSlugValidatorTest extends TestCase
|
||||
|
||||
public static function provideInvalidValues(): iterable
|
||||
{
|
||||
yield ['port:8080'];
|
||||
yield ['foo?bar=baz'];
|
||||
yield ['some-thing#foo'];
|
||||
yield ['call()'];
|
||||
yield ['array[]'];
|
||||
yield ['brackets[]'];
|
||||
yield ['email@example.com'];
|
||||
yield ['wildcard*'];
|
||||
yield ['$500'];
|
||||
}
|
||||
|
||||
public function createValidator(bool $multiSegmentSlugsEnabled = false): CustomSlugValidator
|
||||
|
||||
Reference in New Issue
Block a user