#1029 closed defect (fixed)
Browse cannot download data URIs
Reported by: | lucian | Owned by: | lucian |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | Browse | Version: | 0.84.x |
Severity: | Minor | Keywords: | browse |
Cc: | Distribution/OS: | Ubuntu | |
Bug Status: | Assigned |
Description
Data URIs http://en.wikipedia.org/wiki/Data_URI_scheme
In Firefox, you can right click a link with a data URI and download it. This makes for some really cool tricks, like drawing a picture in a <canvas> and offering it for download as a PNG (http://www.nihilogic.dk/labs/canvas2image/)
Steps to reproduce:
- Load datauri.html in Browse (attached to this ticket)
- Right-click on Text
- In the context menu, click Download
Expected outcome: the URI gets downloaded to the Journal
Actual outcome: nothing happens. Relevant traceback attached
Attachments (5)
Change History (12)
Changed 14 years ago by lucian
comment:1 Changed 14 years ago by lucian
- Owner changed from erikos to lucian
- Status changed from new to assigned
I changed my mind, I'm posting the traceback here.
Traceback (most recent call last):
File "/home/lucian/sugar-jhbuild/install/share/sugar/activities/Browse.activity/palettes.py", line 154, in download_activate_cb
downloadmanager.save_link(self._url, self._title, self._owner_document)
File "/home/lucian/sugar-jhbuild/install/share/sugar/activities/Browse.activity/downloadmanager.py", line 320, in save_link
channel.asyncOpen(listener, None)
File "/usr/lib/xulrunner-1.9.0.10/python/xpcom/client/init.py", line 372, in getattr
self.QueryInterface(iid)
File "/usr/lib/xulrunner-1.9.0.10/python/xpcom/client/init.py", line 336, in QueryInterface
raw_iface = self._comobj_.QueryInterface(iid, 0)
xpcom.Exception: -2147467262 (-2147467262)
comment:2 Changed 14 years ago by lucian
xpcom.Exception: -2147467262 is NS_NOINTERFACE
I've added a print statement in xpcom/client/init.py to show iid
Apparently, the last iid requested is {9277fe09-f0cc-4cd9-bbce-581dd94b0260}, which seems to be nsIHttpChannel.
comment:3 Changed 14 years ago by lucian
- Bug Status changed from New to Assigned
- Priority changed from Low to Normal
I've implemented a workaround in downloadmanager.py, that saves data URIs directly to the Journal. Patch attached.
This is not a proper fix, though. Someone with better knowledge of pyxpcom and xulrunner could probably do it.
comment:4 Changed 14 years ago by lucian
With Tomeu's help, I've made a much smaller patch, http_check.patch. Now the alert shows, but it's text is the actual base64 data. It's still much better than before.
Apparently, if you QueryInterface a pyxpcom object that implements nsIChannel with nsIHttpChannel, it'll think it's nsIHttpChannel.
This patch is still a bit of a workaround, but a much less invasive one.
Changed 14 years ago by lucian
Changed 14 years ago by lucian
comment:5 Changed 14 years ago by lucian
Data URIs now have a default filename, 'data URI'. The download alert is much less ugly.
The Journal objects now read 'data URI from data:mime/type;base64,DaTA...'
comment:6 Changed 14 years ago by erikos
- Resolution set to fixed
- Status changed from assigned to closed
HTML file to reproduce the bug.