servo / rust-url

URL parser for Rust
https://docs.rs/url/
Apache License 2.0
1.27k stars 317 forks source link

Panic in set_path #864

Open Timmmm opened 10 months ago

Timmmm commented 10 months ago
fn main() {
    let mut url = url::Url::parse("file:///d:/test").unwrap();
    url.set_path("d:\\test\\main.foo");
    dbg!(url);
}

Output:

thread 'main' panicked at 'byte index 8 is out of bounds of `file://`', /playground/.cargo/registry/src/index.crates.io-6f17d22bba15001f/url-2.4.0/src/parser.rs:1207:34

Playground.

Timmmm commented 10 months ago

Slightly more minimised:

fn main() {
    let mut url = url::Url::parse("file://").unwrap();
    dbg!(&url);
    url.set_path("x");
    dbg!(&url);
}