-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Correctly set the variant bits of uuid1 #59428
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
Correctly set the variant bits of uuid1 #59428
Conversation
|
8fc4e1c to
6de20c5
Compare
|
Copy and paste error, should be fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me as-is, but if we wanted to define a uuid_variant function that's a bit more general, we could do this:
"""
uuid_variant(u::UUID) :: Symbol
Return UUID variant as one of the following symbols:
- `:NCS`
- `:RFC4122`
- `:Microsoft`
- `:Reserved`
"""
function uuid_variant(u::UUID)
v = UInt8((u.value >> 61) & 0x7)
v ≤ 0x3 ? :NCS_compat :
v ≤ 0x5 ? :RFC4122 :
v ≤ 0x6 ? :Microsoft :
:Reserved
endAsking about the version seems to only make sense if the variant is RFC4122.
|
Better do that in a separate PR since this is a pure bugfix, which can be backported. |
(cherry picked from commit a776445)
(cherry picked from commit a776445)
(cherry picked from commit a776445)
The
uuid1function has been incorrect since it was added to Base in Julia 0.4, in that it fails to set the variant bits specified in section 4.1.1 of RFC 4122. This is fixed in this PR and a test is added.The other implemented uuid versions are doing this correctly.