-
Notifications
You must be signed in to change notification settings - Fork 4
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
Stricter validation of RFC 6901 array indices #80
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
|
Unsurprisingly, this is failing the semver check since I added a new error variant. I don't expect this to happen again, so I don't think we should have I haven't used |
You know, at this point, I must have read that constraint at least 5 times. There was even a moment when I mused on their insistence on no leading zeroes. At no point did my brain recognize that I should actually do something about it. Like it just didn't even register as a potential task. I truly appreciate your help. |
Yea, semver is getting bumped anyway. I'd much rather not go with Awesome catch on the |
Can't take credit, this was a test on
It's pretty subtle. I previously did consider doing an explicit check for all digits, but in my mind the combination of checking for leading zeros + parsing Now I'm wondering if the |
I'm currently leaning toward just keeping the string given its very likely on an error path at that point but then again, perhaps not. |
Yeah, give it some thought. It's not terrible to keep the string, if we decide to. The error path is very unlikely so performance isn't really a concern. Just think it's best we make a conscious call now before committing to it in a release. |
We could add the offset of the first invalid character from within the token. We do that with |
That's not a bad idea. It's generalisable when if we ever do need to support other failure modes. I like it. |
Updated #94 to reflect this. I've now made the error more complex than before, but I think it's worth it. BTW I wonder if we should explore integrating with |
Oh, I forgot all about |
RFC 6901 is very strict about what it allows as an array index. Leading zeros are disallowed, and only digit characters are valid.
I had previously added a check for the leading zeros, but as it turns out that wasn't sufficient. Rust permits
+
as a prefix in a stringifiedusize
, so we're currently more permissive than RFC 6901.I think with this explicit check we finally reach exact parity with RFC 6901 in this aspect.
is_ascii_digit
is documented to check for theU+0030 ‘0’ ..= U+0039 ‘9’.
range exactly, which is what we need.This is a bug fix, though technically breaking.