-
-
Couldn't load subscription status.
- Fork 112
Closed
Description
let schema = jsonschema::compile(&json!({
"type": "string",
"format": "ipv4"
})).unwrap();
println!("{}", schema.is_valid(&json!("0.0.0.0")));This outputs false, when I would expect true because 0.0.0.0 is a valid dotted-quad representation of an IPv4 address. All other IP addresses starting with 0 (e.g. 0.1.2.3) are similarly rejected.
This appears to be due to the fix for json-schema-org/JSON-Schema-Test-Suite#469 (commit 7d32eff), but I think this particular fix is simultaneously:
- too strict, e.g. it rejects 0.0.0.0
- too loose because it allows leading zeroes in the second/third/fourth octets, e.g. it allows 1.0123.1.1
- unnecessary, because
Ipv4Addr'sFromStrimplementation already disallows leading zeros in any octet. Edit: this was only added in rust 1.58 (Reject octal zeros in IPv4 addresses rust-lang/rust#86984), so the explicit check in this crate wasn't unnecessary when it was first implemented!
Metadata
Metadata
Assignees
Labels
No labels