Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: stricter regex; disallow trailing newline #1339

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/EngineBlock/Validator/Urn.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EngineBlock_Validator_Urn
* Taken from: https://stackoverflow.com/a/59048720/5494155
*/
const REGEX = <<<'REGEX'
/\A(?i:urn:(?!urn:)(?<nid>[a-z0-9][a-z0-9-]{1,31}):(?<nss>(?:[-a-z0-9()+,.:=@;$_!*\'&~\/]|%[0-9a-f]{2})+)(?:\?\+(?<rcomponent>.*?))?(?:\?=(?<qcomponent>.*?))?(?:#(?<fcomponent>.*?))?)\z/
/\A(?i:urn:(?!urn:)(?<nid>[a-z0-9][a-z0-9-]{1,31}):(?<nss>(?:[-a-z0-9()+,.:=@;$_!*\'&~\/]|%[0-9a-f]{2})+)(?:\?\+(?<rcomponent>.*?))?(?:\?=(?<qcomponent>.*?))?(?:#(?<fcomponent>.*?))?)\z/D
REGEX;

public function validate(string $urn): bool
Expand Down
1 change: 1 addition & 0 deletions tests/library/EngineBlock/Test/Validator/UrnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function invalidUrnProvider()
yield ['urn:org.openconext.licenseInfo'];
yield ['foo:bar:baz'];
yield ['urn:f:bar'];
yield ["urn:mace:dir:attribute-def:eduPersonPrincipalName\n"];
yield [' urn:collab:person:example.org:jdoe'];
yield ['urn:collab:person:example.org:jdoe '];
yield ['urn:collab:person:example org:jdoe'];
Expand Down