servo / servo/rust-url

host:port string with no scheme parses invalidly

Open
#613 2 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

Trying to parse a string such as a.local.com:3000 should fail, as it does not have a scheme. However, it is allowed to parse, and when .scheme() is called on the resulting Url struct. a.local.com is returned as the scheme. This can cause unexpected behavior and allow invalid URLs to slip through as valid.

This seems to be related to this issue.

Code Sample:

use url::Url;
fn main() {
    let url = Url::parse("a.local.com:3000").unwrap();
    println!("{}, scheme: {}", url.to_string(), url.scheme());
}

Output: a.local.com:3000, scheme: a.local.com

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 at Url::parse and reproduce the issue with the provided a.local.com:3000 example. Trace why the input is accepted with a.local.com as its scheme; done means scheme-less host:port strings are rejected while valid URLs continue to parse correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
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.