Closed
Bug 1193128
Opened 10 years ago
Closed 10 years ago
data URIs are not handled correctly by fetch()
Categories
(Core :: DOM: Service Workers, defect)
Core
DOM: Service Workers
Tracking
()
RESOLVED
FIXED
mozilla43
People
(Reporter: seth, Assigned: nsm)
Details
Attachments
(1 file)
There appears to be a bug in the implementation of fetch for data URIs. I discovered it when trying to fix a bug in test_fetch_event.html. If I replace the code for "nonexistent_image.gif" with this:
> else if (ev.request.url.includes("nonexistent_image.gif")) {
> ev.respondWith(
> fetch(new Request("data:image/gif;base64,R0lGODlhAQABAPAAAP8AAAAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D")));
> }
Then the test fails. Logging the response body from ImageLib, I see that we're just getting "R0lGODlhAQABAP..." as the response body - in other words, the data URI's data is not being properly decoded.
It looks to me like the problem lies here:
https://dxr.mozilla.org/mozilla-central/source/dom/fetch/FetchDriver.cpp#284
I think this code is assuming that nsDataHandler::ParseURI decoded |dataBuffer|, but it looks like ParseURI doesn't do that - it just splits the data URI into parts. We probably need to apply base64 decoding (and possibly URI decoding) manually.
| Reporter | ||
Updated•10 years ago
|
Flags: needinfo?(nsm.nikhil)
Comment 1•10 years ago
|
||
We shipped fetch in 39, so this is probably an issue as far back as that.
status-firefox39:
--- → affected
status-firefox40:
--- → affected
status-firefox41:
--- → affected
status-firefox42:
--- → affected
status-firefox43:
--- → affected
| Assignee | ||
Updated•10 years ago
|
Assignee: nobody → nsm.nikhil
Flags: needinfo?(nsm.nikhil)
| Assignee | ||
Comment 2•10 years ago
|
||
Bug 1193128 - Fix base64 decoding when fetching data URIs. r?baku
Attachment #8647703 -
Flags: review?(amarchesini)
Comment 3•10 years ago
|
||
Comment on attachment 8647703 [details]
MozReview Request: Bug 1193128 - Fix base64 decoding when fetching data URIs. r?baku
https://reviewboard.mozilla.org/r/16035/#review15113
Ship It!
::: dom/fetch/FetchDriver.cpp:284
(Diff revision 1)
> + if (NS_SUCCEEDED(channel->GetContentType(contentType))) {
would be nice to have a:
NS_WARN_IF_NOT(...)
Attachment #8647703 -
Flags: review?(amarchesini) → review+
| Assignee | ||
Comment 4•10 years ago
|
||
url: https://hg.mozilla.org/integration/mozilla-inbound/rev/4d96f2d4807728039747d701d766b67108d96968
changeset: 4d96f2d4807728039747d701d766b67108d96968
user: Nikhil Marathe <nsm.nikhil@gmail.com>
date: Thu Aug 13 13:08:43 2015 -0700
description:
Bug 1193128 - Fix base64 decoding when fetching data URIs. r=baku
| Assignee | ||
Comment 5•10 years ago
|
||
| Assignee | ||
Comment 6•10 years ago
|
||
url: https://hg.mozilla.org/integration/mozilla-inbound/rev/af97951b7f1d68fd60255dc5211206b66a3d0676
changeset: af97951b7f1d68fd60255dc5211206b66a3d0676
user: Nikhil Marathe <nsm.nikhil@gmail.com>
date: Thu Aug 13 13:08:43 2015 -0700
description:
Bug 1193128 - Fix base64 decoding when fetching data URIs. r=baku
Comment 7•10 years ago
|
||
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
You need to log in
before you can comment on or make changes to this bug.
Description
•