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

IsValidGUID validates non-valid GUIDS #5

Open
BarryStokes opened this issue Jun 28, 2017 · 0 comments
Open

IsValidGUID validates non-valid GUIDS #5

BarryStokes opened this issue Jun 28, 2017 · 0 comments

Comments

@BarryStokes
Copy link

The regex looks to be too open and validates anything which has the required number of numbers and dashes but doesn't check for additional data in the string, so things like the following would all pass validation:

"{{00000000-0000-0000-0000-000000000000}}"
"blah{00000000-0000-0000-0000-000000000000}"
"00000000-0000-0000-0000-000000000000n"

If it was changed to the following it might validate better:

m_guidRegex = new Regex("^\\{[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}\\}$");

or

m_guidRegex = new Regex("^\\{{0,1}[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}\\}{0,1}$");

if there was a need to pass as valid a string which wasn't bounded by curly braces.

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

No branches or pull requests

1 participant