MakeAbsolute broken for 'file:' URLs that don't end with '/'

VERIFIED INVALID

Status

()

defect
P3
normal
VERIFIED INVALID
20 years ago
3 years ago

People

(Reporter: waterson, Assigned: gagan)

Tracking

Trunk
x86
Windows NT
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

The current implementation of nsFileProtocol::NewURI() breaks when the base URI
does not end with a '/' character; specifically, it _replaces_ the filename,
instead of concatenating it.

Try this HTML on for size:

<html>
<body>
<script>
function foo()
{
  var ios =
Components.classes['component://netscape/network/net-service'].getService();
  ios = ios.QueryInterface(Components.interfaces.nsIIOService);

  var uri = ios.NewURI("file:///C|/tmp", null);
  var uri2 = ios.NewURI("baz.txt", uri);

  dump("uri2.Spec == " + uri2.Spec + "\n");
}
</script>
<button onclick="foo();">click me!</button>
</body>
</html>

It will print "file:///C|/baz.txt", I'd expect "file:///C|/tmp/baz.txt". It
turns out that you _can_ get this result by appending a '/' to the end of the
spec passed in to create 'uri' (e.g., "file:///C|/tmp/").
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Chris I believe MakeAbsoluteURL is doing the right thing. The problem is that
URL parsing alone does not know that tmp stands for a directory. What if tmp is
a file sitting in C:\ ? If you know for sure that tmp is a directory then follow
it with a trailing slash. Otherwise the way parses it, its doing the right
thing.
Bulk move of all Necko (to be deleted component) bugs to new Networking

component.
Thanks!
QA Contact: paulmac → tever
Sorry for the spam, changing QA contact.
verified
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.