rust-url: Properly log validation errors related to legacy IPv4 notations
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:
# all are treated as equivalent to http://127.0.0.1/
http://127.0.1/
http://127.1/
http://0177.0.1/
http://0177.0.0.1/
http://0177.1/
http://0x7f.0.1/
http://0x7f.0.0.1/
http://0x7f.1/
http://2130706433/
http://0x7f000001/
http://017700000001/
# equivalent to http://127.0.0.8/ , not http://127.0.0.10/
http://0127.0.0.010/
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.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 1
- Comments: 15 (13 by maintainers)
Commits related to this issue
- Auto merge of #525 - dekellum:future-proof, r=SimonSapin Add unused variants to ParseError and SyntaxViolation enums Per discussion in https://github.com/servo/rust-url/issues/498#issuecomment-51329... — committed to servo/rust-url by deleted user 5 years ago
- Auto merge of #525 - dekellum:future-proof, r=SimonSapin Add unused variants to ParseError and SyntaxViolation enums Per discussion in https://github.com/servo/rust-url/issues/498#issuecomment-51329... — committed to servo/rust-url by deleted user 5 years ago
I think it would be ok adding a
doc(hidden)variant and making it extra clear in the docs that this enum is never expected to be exhaustively matched.@dekellum re
The POSIX spec for
getaddrinfosays that “address strings using Internet standard dot notation as specified in inet_addr are valid”, and that does include all of the unusual syntaxes I listed.