servo / servo/rust-url

Panic for `file` while using base

Open Beginner friendly
#1,114 1 comment 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

  • Note that this crate implements the URL Standard not RFC 1738 or RFC 3986

Describe the bug

Testcase:

#[test]
fn test_file_base_panic() {
    let base_url = Url::parse("file:///w:/a:").unwrap();
    Url::options().base_url(Some(&base_url)).parse("file:..");
}

Backtrace:

thread 'test_file_base_panic' (377458) panicked at url/src/parser.rs:1321:21:
assertion failed: self.serialization.as_bytes()[segment_start - 1] == b'/'
stack backtrace:
< skipped >
  19:     0x57a3a138611c - core::panicking::panic::hb515f22c0e98143a
                               at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/panicking.rs:145:5
  20:     0x57a3a12cfb59 - url::parser::Parser::parse_path::h69b46743c9367ec2
                               at /home/wooffie/work/upstream/rust-url/url/src/parser.rs:1321:21
  21:     0x57a3a12cd0d9 - url::parser::Parser::parse_file::h88e81c17dec524c5
                               at /home/wooffie/work/upstream/rust-url/url/src/parser.rs:659:46
  22:     0x57a3a12d3896 - url::parser::Parser::parse_with_scheme::h31ca21d8147c599c
                               at /home/wooffie/work/upstream/rust-url/url/src/parser.rs:446:22
  23:     0x57a3a12d637d - url::parser::Parser::parse_url::hadfb176b92197e15
                               at /home/wooffie/work/upstream/rust-url/url/src/parser.rs:382:25
  24:     0x57a3a12af420 - url::ParseOptions::parse::hf1b29cfaa662d5f3
                               at /home/wooffie/work/upstream/rust-url/url/src/lib.rs:314:10
  25:     0x57a3a124735b - unit::test_file_base_panic::h46e4b9e042615051
                               at /home/wooffie/work/upstream/rust-url/url/tests/unit.rs:725:46

ref #838

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 in url/src/parser.rs at Parser::parse_file and Parser::parse_path, using the file-base testcase from the issue and the related test area in url/tests/unit.rs. Reproduce the panic, trace the path handling around the reported assertion, and add or update a regression test. Done means the testcase parses without panicking and the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.