Skip to content

Commit e68318e

Browse files
committed
Prevent UUIDs with newlines from validating, fixes #307
1 parent 38b09f4 commit e68318e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Assert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,7 @@ public static function uuid($value, $message = '')
21632163
return;
21642164
}
21652165

2166-
if (!\preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) {
2166+
if (!\preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/D', $value)) {
21672167
static::reportInvalidArgument(\sprintf(
21682168
$message ?: 'Value %s is not a valid UUID.',
21692169
static::valueToString($value)

tests/AssertTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ public function getTests()
537537
array('uuid', array('ff6f8cb0-c57d-41e1-9b21-0800200c9a66'), true),
538538
array('uuid', array('ff6f8cb0-c57d-51e1-9b21-0800200c9a66'), true),
539539
array('uuid', array('FF6F8CB0-C57D-11E1-9B21-0800200C9A66'), true),
540+
array('uuid', array("urn:ff6f8cb0-c57d-21e1-9b21-0800200c9a66\n"), false),
541+
array('uuid', array("ff6f8cb0-c57d-21e1-9b21-0800200c9a66\n"), false),
542+
array('uuid', array("FF6F8CB0-C57D-11E1-9B21-0800200C9A66\n"), false),
540543
array('uuid', array('zf6f8cb0-c57d-11e1-9b21-0800200c9a66'), false),
541544
array('uuid', array('af6f8cb0c57d11e19b210800200c9a66'), false),
542545
array('uuid', array('ff6f8cb0-c57da-51e1-9b21-0800200c9a66'), false),

0 commit comments

Comments
 (0)