servo / servo/rust-url

Panic in `Url::set_host`

Open
#662 0 comments 0 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

While working on creating a more extensive fuzzing target as in https://github.com/servo/rust-url/issues/654 I found this panic:

#[test]
    let mut url = Url::parse("\nx--n://\u{b}#.").unwrap();
    dbg!(&url);
    /*
    Url {
        scheme: "x--n",
        host: Some(
            Domain(
                "%0B",
            ),
        ),
        port: None,
        path: "",
        query: None,
        fragment: Some(
            ".",
        ),
        username: "",
        password: None,
    }
    */
    url.set_host(None).unwrap();

panicked at 'assertion failed: self.byte_at(self.path_start) == b'/'', url/src/lib.rs:1685:13

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 reproducer in the issue and inspect url/src/lib.rs around line 1685, where Url::set_host(None) triggers the assertion. Trace how the parsed URL's host, path, and path_start are represented before set_host runs. Done means the reproducer no longer panics and a regression test covers this input.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.