google / google/uuid

Parsing "Microsoft encoding" is very lenient

Open
#60 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6.1k
Forks
440
PR merge metrics
No merged PRs in 30d

Description

I was reading through the code for Parse and I noticed that there is no validation on the first and last characters of the uuid-to-parse when the length of the input is 38 characters:

https://github.com/google/uuid/blob/16ca3eab7d2086fd5a82993a291cbf3b87fe38b7/uuid.go#L38-L61

I would expect there to be a check that `s[0] == '{' && s[37] == '}'` rather than simply ignoring those two characters. I am happy to send a PR if requested, it's a simple change. I am just verifying that this loose behavior is not actually desired.

(fwiw, it means that parsing something like `a01234567-abcd-cdef-abcd-012345678901a` would be parsed without an error, even though it has extra characters at the beginning and end. That's quite unexpected IMO.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.