URL constructor fails when input is a data URL without a comma
Categories
(Core :: DOM: Core & HTML, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox71 | --- | fixed | 
People
(Reporter: saschanaz, Assigned: valentin)
References
(Depends on 1 open bug)
Details
Attachments
(1 file)
new URL("data:foo");
All Chrome, Edge, and Safari successfully can create a URL instance but Firefox fails to do so.
I suspect this should be a duplicate but couldn't find any existing relevant bug.
| Comment 2•6 years ago
           | ||
In URL API, we call NS_NewURI() and this returns an error when parsing data:foo.
See: https://searchfox.org/mozilla-central/rev/2c0a60b5b065ae0fdfcfae168141e82b834fb2d4/dom/url/URL.cpp#68
Because the URL doesn't contain a comma, we return NS_ERROR_MALFORMED_URI:
https://searchfox.org/mozilla-central/rev/2c0a60b5b065ae0fdfcfae168141e82b834fb2d4/netwerk/protocol/data/nsDataHandler.cpp#159
Valentin is on PTO. Dragana, who can take a look whether this is a bug in our data: URL parser?
| Comment 3•6 years ago
          • | ||
Doesn't seem like the comma is optional according to https://tools.ietf.org/html/rfc2397, which says it's
data:[<mediatype>][;base64],<data>
and wikipedia says
The comma is required in a data URI, even when the data part has zero length.
| Reporter | ||
| Updated•6 years ago
           | 
| Reporter | ||
| Comment 4•6 years ago
          • | ||
The URL standard doesn't seem to reference RFC 2397 nor require a valid data URI.
Edit: There are several relevant WPT test failures https://searchfox.org/mozilla-central/rev/2c0a60b5b065ae0fdfcfae168141e82b834fb2d4/testing/web-platform/meta/url/url-constructor.html.ini
| Comment 5•6 years ago
           | ||
Yeah, this is a bug in Firefox not using a compliant URL parser (one that covers all schemes and does not dispatch on a per-scheme basis).
| Assignee | ||
| Comment 7•6 years ago
           | ||
The fix seems simple enough.
| Assignee | ||
| Comment 8•6 years ago
           | ||
|   | ||
| Comment 10•6 years ago
           | ||
Backed out changeset d0fb6559c22e (Bug 1579331) for failing in browser_contextmenu.js CLOSED TREE
Push with failure: https://treeherder.mozilla.org/#/jobs?repo=autoland&selectedJob=266141844&resultStatus=testfailed%2Cbusted%2Cexception&revision=d0fb6559c22ec8cbe5f4eeb15ebbaa549fb3e106
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=266141844&repo=autoland&lineNumber=2882
Backout: https://hg.mozilla.org/integration/autoland/rev/5b2288a607cb020a24ccc3f8be0469b2007dd742
| Comment 11•6 years ago
           | ||
| Assignee | ||
| Updated•6 years ago
           | 
|   | ||
| Comment 12•6 years ago
           | ||
| bugherder | ||
Description
•