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

Should check the last byte in Id::from_str #9

Closed
zensh opened this issue Jun 6, 2023 · 1 comment
Closed

Should check the last byte in Id::from_str #9

zensh opened this issue Jun 6, 2023 · 1 comment

Comments

@zensh
Copy link
Contributor

zensh commented Jun 6, 2023

A bad case:

let s = "00000000000000jarvis";
assert_eq!(Id::from_str(s).unwrap().to_string().as_str(), s);

thread 'id::tests::test_from_str_should_check' panicked at 'assertion failed: (left == right)
left: "00000000000000jarvig",
right: "00000000000000jarvis"'

https://github.com/rs/xid/blob/master/id.go#L267

zensh added a commit to yiwen-ai/xid-rs that referenced this issue Jun 13, 2023
Signed-off-by: 0xZensh <txr1883@gmail.com>
@kazk
Copy link
Owner

kazk commented Oct 12, 2023

Sorry, I just noticed this. So the original issue is rs/xid#71, and we need to reject invalid strings not generated by xid, which can be done efficiently by checking the last byte.
Thanks, I'll review the PR soon.

@kazk kazk closed this as completed in cb6028b Apr 23, 2024
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

2 participants