-
Notifications
You must be signed in to change notification settings - Fork 346
Properly log validation errors related to legacy IPv4 notations #498
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
Comments
I wasn't aware of this legacy edge case (thanks!), but I agree with your motivation. Seems exploitable for misuse. For example servers might have good reason to want to reject provided URLs to localhost. Do common IPv4 resolvers actually accept and resolve these examples to local ports? If the violation callback was extended for this case, you would have the option of promoting the violation to your own error or other form of rejection? That would be a light-weight and (I think, reasonably) backward-compatible way to achieve it, while still making the implementation available in this crate. I'd use that! |
That would work for me except that in #462 it’s proposed to remove the
syntax violation callback.
|
Indeed! I've suggested keeping it. :) |
Aligning with the spec in terms of what inputs log a syntax violation sounds good. |
@dekellum re
The POSIX spec for |
@SimonSapin : Thanks. I think anyone implementing would be concerned about #462 Is it a reasonable time to decide that either way? |
AFAIK if we want to do that we need a new variant for the syntax violation enum, so this will be a breaking change, so we want to do that for 2.0 I guess. |
Would discouraging exhaustive matching (in itself a breaking change) on |
It looks like |
Okay, would you entertain a PR to add an unused variant and rustdoc to each of these enums? |
Also, having looked at these error types, they are in need of some other modernizations, like dropping description() impl and replacing with a Display impls. I could do that in same PR. Of interest? |
I think it would be ok adding a |
Nah please leave that alone, no need to regress things for no reason and the implementation is trivial. You can definitely add a Display impl though. |
IIRC, current |
You can click on the |
Add unused variants to ParseError and SyntaxViolation enums Per discussion in #498 (comment) , this adds a hidden unused variant to each of `ParseError` and `SyntaxViolation` enums so as to make future additions non-breaking changes. This is the long standing manual way (e.g. originally used by`std::io::ErrorKind`), given lack of a stable feature and acceptable rust MSRV with rust-lang/rust#44109. Also these types already implemented `Display` but having been burnt with `Debug` vs `Display` versions of the `fmt` function, I also disambiguated paths in these `Display` implementations. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/525) <!-- Reviewable:end -->
Add unused variants to ParseError and SyntaxViolation enums Per discussion in #498 (comment) , this adds a hidden unused variant to each of `ParseError` and `SyntaxViolation` enums so as to make future additions non-breaking changes. This is the long standing manual way (e.g. originally used by`std::io::ErrorKind`), given lack of a stable feature and acceptable rust MSRV with rust-lang/rust#44109. Also these types already implemented `Display` but having been burnt with `Debug` vs `Display` versions of the `fmt` function, I also disambiguated paths in these `Display` implementations. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/525) <!-- Reviewable:end -->
The current rev of the URL Standard specifies that the various legacy notations accepted by
inet_aton
for IPv4 addresses are validation errors, but rust-url silently accepts them (they're not even diagnosed via the syntax violation callback). I would like to have an option to reject these.Examples of undesirable constructs:
See https://url.spec.whatwg.org/#concept-ipv4-parser (pay close attention to where it, and its subroutine https://url.spec.whatwg.org/#ipv4-number-parser , set the "validationErrorFlag") for gory details.
Previous discussion in #116.
The text was updated successfully, but these errors were encountered: