Don't allow UUIDs to have trailing newline

This commit is contained in:
Lee Boynton
2018-05-02 18:50:59 +01:00
parent 29fb62b486
commit 2804748423
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -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;
}
+9
View File
@@ -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()