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

Decoding an invalid uuid shouldn't work #29

Open
soyuka opened this issue Oct 6, 2018 · 1 comment
Open

Decoding an invalid uuid shouldn't work #29

soyuka opened this issue Oct 6, 2018 · 1 comment

Comments

@soyuka
Copy link

soyuka commented Oct 6, 2018

Hi,

When we try to decode something that isn't a valid uuid it works, IMO it should throw an error:

$uuid = 'notanuuid';
(new ShortUuid())->decode($uuid); // should throw
@juliangut
Copy link

juliangut commented Jan 30, 2019

I've just bumped into this problem

The thing is decoding 'notanuuid' actually returns '00000000-0000-0000-000e-23c92ffab638' which by Ramsey's validation regex is perfectly valid as per this issue comment

So I guess what can be done right now is accept that any UUID that comes out of decode method is valid (as per Ramsey's) or at best add a check to validate UUID version and variant against RFC 4122

Validation is just being moved to a validator class for version 4.x, so lets hope for different kinds of validators to be available

Edit:
You can have a look at how I've implemented it: https://github.com/phpgears/identity/blob/master/src/ShortUuidIdentity.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants