The default bug view has changed. See this FAQ.

The URI "file://" doesn't handle hash references correctly

RESOLVED FIXED

Status

()

Core
Networking
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: dholbert, Assigned: jesup)

Tracking

Trunk
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(crash signature)

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
I've been writing an extensive xpcshell test for parsing references from URIs/URLs for bug 308590, and I've discovered that the URI "file://" doesn't handle references correctly.

In particular, if I do (e.g. in xpcshell):
> js> var foo = NetUtil.newURI("file://#myRef")   
> js> foo.spec
> file:///

(I'd expect the above to say "file:///#myRef". Note that the parser inserts an extra "/" for the path, which is fine, but I'd hope that it'd preserve the #myRef, too.)

For comparison, here's the result with http:
> js> var foo = NetUtil.newURI("http://#myRef")
> js> foo.spec
> http:///#myRef
(note that here, too, the parser inserts an extra "/", but in this case it preserves the #myRef.)
(Reporter)

Comment 1

6 years ago
Note that the issue goes away if my input has 3 slashes instead of 2 -- e.g.:
> js> var foo = NetUtil.newURI("file:///#myRef")    // note the triple-slash!
> js> foo.spec
> file:///#myRef
          ^yay!

Given that file:// and file:/// end up parsing to the same URI, I'd expect that I'd be able to append a reference to both of those input strings, and still produce equal URIs.

(This holds for "http://" and "http:///", for example -- appending #myRef to each of those produces URIs that are equal to each other.)
Blocks: 657033
Depends on: 648626
(Assignee)

Comment 2

6 years ago
Created attachment 545156 [details] [diff] [review]
Patch to fix this and update tests (assumes patch for bug 622981 is applied)
Assignee: nobody → rjesup
Status: NEW → ASSIGNED
Attachment #545156 - Flags: review?(bzbarsky)
Comment on attachment 545156 [details] [diff] [review]
Patch to fix this and update tests (assumes patch for bug 622981 is applied)

r=me
Attachment #545156 - Flags: review?(bzbarsky) → review+
(Assignee)

Comment 4

6 years ago
Checked in: http://hg.mozilla.org/mozilla-central/rev/26c113f4780a
Status: ASSIGNED → RESOLVED
Crash Signature: d
Last Resolved: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.