Skip to content

Fix uuid() accepting {, }, and prefixes inside the string#359

Merged
shadowhand merged 2 commits into
webmozarts:masterfrom
edorian:fix-uuid-accepted-values
Jun 15, 2026
Merged

Fix uuid() accepting {, }, and prefixes inside the string#359
shadowhand merged 2 commits into
webmozarts:masterfrom
edorian:fix-uuid-accepted-values

Conversation

@edorian

@edorian edorian commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Hi,

A hopefully small fix for UUIDs being allowed to contain the prefixes and {} inside the string.

If you'd prefer the regular expression to be multiple and commented inline, I'd be happy to do that as well.

I hope the test cases are self-explanatory regarding the behavioral changes.

Moved the validation into the regex:

  • The prefixes are only accepted at the start
  • A leading "{" must be paired with a closing "}" using a PCRE conditional

Instead of stripping "urn:", "uuid:", "{" and "}" from anywhere in the value before matching.

So strings like "5{}50e8400-..." or an interior "urn:" passed the assertion and the un-normalised string was returned to the caller.

Moved the validated into the regex:

- The prefixes are only accepted at the start
- A leading "{" must be paired with a closing "}" using a PCRE conditional
Comment thread src/Assert.php Outdated
Comment thread src/Assert.php
Comment thread tests/AssertTest.php Outdated
@edorian edorian requested a review from shadowhand June 15, 2026 13:27
@edorian

edorian commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@shadowhand Updated as per your comments

@shadowhand shadowhand merged commit 85fa1a6 into webmozarts:master Jun 15, 2026
9 checks passed
@shadowhand

Copy link
Copy Markdown
Collaborator

Released in 2.4.1.

@edorian edorian deleted the fix-uuid-accepted-values branch June 15, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants