diff --git a/CHANGELOG.md b/CHANGELOG.md index a75e39ed..5eecc684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this #### Fixed * [#665](https://github.com/shlinkio/shlink/issues/665) Fixed `base_url_redirect_to` simplified config option not being properly parsed. +* [#663](https://github.com/shlinkio/shlink/issues/663) Fixed Shlink allowing short URLs to be created with an empty custom slug. ## 2.0.5 - 2020-02-09 diff --git a/composer.json b/composer.json index 7b8bf39e..84707645 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "predis/predis": "^1.1", "pugx/shortid-php": "^0.5", "ramsey/uuid": "^3.9", - "shlinkio/shlink-common": "^2.7.0", + "shlinkio/shlink-common": "^2.8.0", "shlinkio/shlink-event-dispatcher": "^1.3", "shlinkio/shlink-installer": "^4.2.0", "shlinkio/shlink-ip-geolocation": "^1.3.1", diff --git a/module/Core/src/Validation/ShortUrlMetaInputFilter.php b/module/Core/src/Validation/ShortUrlMetaInputFilter.php index 6237daf7..013edd8f 100644 --- a/module/Core/src/Validation/ShortUrlMetaInputFilter.php +++ b/module/Core/src/Validation/ShortUrlMetaInputFilter.php @@ -44,7 +44,10 @@ class ShortUrlMetaInputFilter extends InputFilter // empty, is by using the deprecated setContinueIfEmpty $customSlug = $this->createInput(self::CUSTOM_SLUG, false)->setContinueIfEmpty(true); $customSlug->getFilterChain()->attach(new Validation\SluggerFilter()); - $customSlug->getValidatorChain()->attach(new Validator\NotEmpty(Validator\NotEmpty::STRING)); + $customSlug->getValidatorChain()->attach(new Validator\NotEmpty([ + Validator\NotEmpty::STRING, + Validator\NotEmpty::SPACE, + ])); $this->add($customSlug); $this->add($this->createPositiveNumberInput(self::MAX_VISITS)); diff --git a/module/Core/test/Model/ShortUrlMetaTest.php b/module/Core/test/Model/ShortUrlMetaTest.php index fed2c662..7d0dd9b6 100644 --- a/module/Core/test/Model/ShortUrlMetaTest.php +++ b/module/Core/test/Model/ShortUrlMetaTest.php @@ -47,6 +47,15 @@ class ShortUrlMetaTest extends TestCase yield [[ ShortUrlMetaInputFilter::SHORT_CODE_LENGTH => 3, ]]; + yield [[ + ShortUrlMetaInputFilter::CUSTOM_SLUG => '/', + ]]; + yield [[ + ShortUrlMetaInputFilter::CUSTOM_SLUG => '', + ]]; + yield [[ + ShortUrlMetaInputFilter::CUSTOM_SLUG => ' ', + ]]; } /** @test */