servo/rust-url

Failed round trip in fuzzer (EmptyHost)

5225225 opened this issue · 1 comments

The fuzzer on 0840723 found this case which doesn't round-trip.

fn main() {
    let u = url::Url::parse("p:/.//:/").unwrap();
    let s = u.as_str();
    assert_eq!(s, "p://:/"); // the `/.` was lost
    url::Url::parse("p://:/").unwrap(); // which causes this to error
}

Also, the fuzzer can be simplified to not need the UTF-8 check by doing

fuzz_target!(|data: &str| {
    if let Ok(parsed) = url::Url::parse(data) {
        let as_str = parsed.as_str();
        assert_eq!(parsed, url::Url::parse(as_str).unwrap());
    }
});

The fuzzer on 48fcbe1 still ran into this same yet shorter case: A:/.//: .