servo / servo/rust-url

windows: to_file_path() panics for certain URLs created by from_file_path()

Open
#505 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

use std::path::PathBuf;
use url::Url;

fn main() {
    let p = PathBuf::from("c:///");
    let u = Url::from_file_path(p).unwrap();
    println!("url: {:?}", u);
    let r = u.to_file_path();  // <-- Panic happens here
    println!("result: {:?}", r);
}

output:

url: "file:///C:"
thread 'main' panicked at 'to_file_path() failed to produce an absolute Path', C:\Users\BertBelder\.cargo\registry\src\github.com-1ecc6299db9ec823\url-1.7.2\src\lib.rs:2415:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: process didn't exit successfully: `target\debug\urlt.exe` (exit code: 101)

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

Reproduce the Windows panic with the Rust example, then inspect src/lib.rs around to_file_path() and its interaction with from_file_path(). Add regression coverage for the shown c:/// URL and verify that converting the generated URL back to a file path no longer panics.

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.