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

fix(prost-types): '+' is not a numeric digit #1104

Merged
merged 1 commit into from
Jul 13, 2024

Conversation

mumbleskates
Copy link
Contributor

u8 as FromStr tolerates a leading + character, so before this change for any 2-digit component of the path, "05" and "+5" are basically equivalent. we shouldn't tolerate this, it's weird.

Copy link
Collaborator

@caspermeijn caspermeijn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find. Thanks for your contribution!

@@ -330,6 +330,9 @@ fn parse_two_digit_numeric(s: &str) -> Option<(u8, &str)> {
if s.len() < 2 {
return None;
}
if s.starts_with('+') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The digits.parse function will eventually call u8::from_str_radix, which allows to an optional + and then only digits. So checking for the + as the first character is enough to get all the weird cases of parse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that seems to be the case!

@caspermeijn caspermeijn added this pull request to the merge queue Jul 13, 2024
Merged via the queue into tokio-rs:master with commit 366c6fb Jul 13, 2024
16 checks passed
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

Successfully merging this pull request may close these issues.

2 participants