This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 26341 - file scheme without a base URL
Summary: file scheme without a base URL
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: URL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: Unsorted
Assignee: Anne
QA Contact: sideshowbarker+urlspec
URL:
Whiteboard:
Keywords:
Depends on: 25946
Blocks:
  Show dependency treegraph
 
Reported: 2014-07-15 18:43 UTC by Simon Sapin
Modified: 2015-08-14 06:19 UTC (History)
2 users (show)

See Also:


Attachments

Description Simon Sapin 2014-07-15 18:43:32 UTC
The parser’s scheme state contains:
> If url's scheme is "file", set state to relative state.

This can happen with a null (not given) base URL, but then the relative state goes on accessing components of the base URL:

> "?"
> Set url's host to base's host, url's port to base's port, url's path to base's path, url's query to the empty string, and state to query state.

Test cases:

new URL("file:")
new URL("file:?foo")
new URL("file:#foo")


The parsing algorithm could be clearer with a separate handling of file: URLs between the scheme state and the path/query/fragment states.
Comment 1 Sam Ruby 2014-11-05 21:34:48 UTC
http://intertwingly.net/projects/pegurl/url.html separates out file: URLs.  Should this approach be adopted, what more needs to be done here?
Comment 2 Anne 2015-08-14 06:19:48 UTC
Thank you Simon. I fixed this with this commit, which introduces several new file-specific states:

https://github.com/whatwg/url/commit/09cd673a338e7abc552140d950c4f34d7d71362a

It also resolves a number of other issues around file URLs, though it'll still need more verification and tests.