From 9f6b6bb0b9be8f11d11097498ce8e6e5a4c018ca Mon Sep 17 00:00:00 2001 From: Barry O Sullivan Date: Mon, 24 Jul 2017 16:07:16 +0100 Subject: [PATCH] Fixing a bug where it accepted overly long UUIDs --- composer.lock | 56 +++++++++---------- src/ValueObject/Uuid.php | 2 +- test/Deserializer/CompositeErrorReporting.php | 2 +- test/ValueObject/Uuid.php | 6 ++ 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/composer.lock b/composer.lock index 5fcc0c1..959bfde 100644 --- a/composer.lock +++ b/composer.lock @@ -319,16 +319,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" + "reference": "f29dca382a6485c3cbe6379f0c61230167681937" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937", + "reference": "f29dca382a6485c3cbe6379f0c61230167681937", "shasum": "" }, "require": { @@ -340,7 +340,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -374,20 +374,20 @@ "portable", "shim" ], - "time": "2016-11-14 01:06:16" + "time": "2017-06-09 14:24:12" }, { "name": "symfony/translation", - "version": "v3.3.2", + "version": "v3.3.5", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "dc3b2a0c6cfff60327ba1c043a82092735397543" + "reference": "35dd5fb003c90e8bd4d8cabdf94bf9c96d06fdc3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/dc3b2a0c6cfff60327ba1c043a82092735397543", - "reference": "dc3b2a0c6cfff60327ba1c043a82092735397543", + "url": "https://api.github.com/repos/symfony/translation/zipball/35dd5fb003c90e8bd4d8cabdf94bf9c96d06fdc3", + "reference": "35dd5fb003c90e8bd4d8cabdf94bf9c96d06fdc3", "shasum": "" }, "require": { @@ -439,7 +439,7 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2017-05-22 07:42:36" + "time": "2017-06-24 16:45:30" } ], "packages-dev": [ @@ -595,22 +595,22 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.1.1", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" + "reference": "46f7e8bb075036c92695b15a1ddb6971c751e585" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/46f7e8bb075036c92695b15a1ddb6971c751e585", + "reference": "46f7e8bb075036c92695b15a1ddb6971c751e585", "shasum": "" }, "require": { "php": ">=5.5", "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.2.0", + "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { @@ -636,24 +636,24 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-09-30 07:12:33" + "time": "2017-07-15 11:38:20" }, { "name": "phpdocumentor/type-resolver", - "version": "0.2.1", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", "shasum": "" }, "require": { - "php": ">=5.5", + "php": "^5.5 || ^7.0", "phpdocumentor/reflection-common": "^1.0" }, "require-dev": { @@ -683,7 +683,7 @@ "email": "me@mikevanriel.com" } ], - "time": "2016-11-25 06:54:22" + "time": "2017-07-14 14:27:02" }, { "name": "phpspec/prophecy", @@ -1596,16 +1596,16 @@ }, { "name": "symfony/yaml", - "version": "v3.3.2", + "version": "v3.3.5", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063" + "reference": "1f93a8d19b8241617f5074a123e282575b821df8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/9752a30000a8ca9f4b34b5227d15d0101b96b063", - "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063", + "url": "https://api.github.com/repos/symfony/yaml/zipball/1f93a8d19b8241617f5074a123e282575b821df8", + "reference": "1f93a8d19b8241617f5074a123e282575b821df8", "shasum": "" }, "require": { @@ -1647,7 +1647,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-06-02 22:05:06" + "time": "2017-06-15 12:58:50" }, { "name": "webmozart/assert", diff --git a/src/ValueObject/Uuid.php b/src/ValueObject/Uuid.php index 8f2071b..663314b 100644 --- a/src/ValueObject/Uuid.php +++ b/src/ValueObject/Uuid.php @@ -7,7 +7,7 @@ class Uuid extends Type\AbstractSingleValue implements Identifier { protected function validator() { - return parent::validator()->regex('/([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}?)/i'); + return parent::validator()->regex('/([a-f\d]{8}(-[a-f\d]{4}){3}-[a-f\d]{12}?)$/i'); } public function is_null() diff --git a/test/Deserializer/CompositeErrorReporting.php b/test/Deserializer/CompositeErrorReporting.php index 8289c9a..059ba58 100644 --- a/test/Deserializer/CompositeErrorReporting.php +++ b/test/Deserializer/CompositeErrorReporting.php @@ -26,7 +26,7 @@ public function test_reporting_when_values_are_wrong() $exception = $this->fail_elegantly($encoded); $expected = [ - "id" => ['"1234" must validate against "/([a-f\\\\d]{8}(-[a-f\\\\d]{4}){3}-[a-f\\\\d]{12}?)/i"'], + "id" => ['"1234" must validate against "/([a-f\\\\d]{8}(-[a-f\\\\d]{4}){3}-[a-f\\\\d]{12}?)$/i"'], "date" => ['"saads" must be a valid date'] ]; diff --git a/test/ValueObject/Uuid.php b/test/ValueObject/Uuid.php index 95bde31..2e293af 100644 --- a/test/ValueObject/Uuid.php +++ b/test/ValueObject/Uuid.php @@ -15,4 +15,10 @@ public function test_invalid_value() $this->setExpectedException(Assert\Exception::class); new Uuid("asdfasdf"); } + + public function test_fails_if_the_uuid_is_too_long() + { + $this->setExpectedException(Assert\Exception::class); + new Uuid("ac9e4e83-5495-4a58-90d9-eeeaf3989bc8a"); + } } \ No newline at end of file