diff --git a/src/Uuid.php b/src/Uuid.php index fa07aa5..bccc7f7 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -654,7 +654,7 @@ class Uuid implements UuidInterface return true; } - if (!preg_match('/' . self::VALID_PATTERN . '/', $uuid)) { + if (!preg_match('/' . self::VALID_PATTERN . '/D', $uuid)) { return false; } diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 918b684..9cf2a17 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -88,6 +88,15 @@ class UuidTest extends TestCase $uuid = Uuid::fromString('ff6f8cb0-c57d-11e1-9b21'); } + /** + * @expectedException \Ramsey\Uuid\Exception\InvalidUuidStringException + * @expectedExceptionMessage Invalid UUID string: + */ + public function testFromStringWithTrailingNewLine() + { + Uuid::fromString("d0d5f586-21d1-470c-8088-55c8857728dc\n"); + } + /** */ public function testFromStringWithUrn()