Open Bug 359901 Opened 18 years ago Updated 2 years ago

nsSimpleURI::SetSpec misidentifies nsIURI::prePath and ::path for HTTP URLs

Categories

(Core :: Networking, enhancement, P5)

enhancement

Tracking

()

People

(Reporter: myk, Unassigned)

Details

(Whiteboard: [necko-would-take])

nsSimpleURI appears to handle HTTP URLs (it doesn't throw an exception when you hand it one via SetSpec, and it implements nsIURI, which provides properties for all the individual segments of those URLs), but it incorrectly identifies the pre-paths and paths of those URLs. Instead of identifying the pre-path as everything up to and including the host:port and the path as everything after that (per the documentation in nsIURI.idl), it identifies the pre-path as the scheme and the path as everything after that. To reproduce, execute the following code in the error console: var uri = Components.classes["@mozilla.org/network/simple-uri;1"].createInstance(Components.interfaces.nsIURI); uri.spec = "http://www.example.com/index.html"; "pre-path: " + uri.prePath + "\npath: " + uri.path Expected Results: pre-path: http://www.example.com path: /index.html Actual Results: pre-path: http: path: //www.example.com/index.html nsSimpleURI is chopping up the URL as designed, since it was designed for simple URIs like data: URLs. But since it doesn't really implement nsIURI properly for HTTP URLs, it probably shouldn't pretend to handle them and throw an exception when handed one (or when handed any other complex URL it doesn't handle). But this is just a symptom of a larger problem, about which darin says on IRC: <darin> myk: we've struggled since i started working on moz to get people to not instantiate nsSimpleURI and nsStandardURL directly <darin> myk: i think the answer is to remove those factories altogether and replace them with some constructor method on an interface named something like"nsIProtocolHandlerUtils" <darin> myk: or "nsIProtocolHandlerImplementationUtils_really_dont_touch_this_unless_you_are_implementing_nsIProtocolHandler"
Whiteboard: [necko-would-take]
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.