servo / servo/rust-url

Failed round trip in fuzzer (EmptyHost)

Open
#729 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.6k
Forks
406
PR merge metrics
No merged PRs in 30d

Description

The fuzzer on 08407234528e1ee 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());
    }
});

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported Url::parse and as_str round-trip using the EmptyHost example, then run the fuzzer case from the issue. Trace how the p:/.//:/ input is serialized and reparsed, and consider the issue done when the /. segment is preserved and the simplified round-trip assertion passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.