Ticket #1029 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

Browse cannot download data URIs

Reported by: lucian Owned by: lucian
Priority: Normal Milestone: 0.86
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:
1. Load datauri.html in Browse (attached to this ticket)
2. Right-click on Text
3. In the context menu, click Download

Expected outcome: the URI gets downloaded to the Journal

Actual outcome: nothing happens. Relevant traceback attached

Attachments

datauri.html Download (443 bytes) - added by lucian 4 years ago.
HTML file to reproduce the bug.
datauri_workaround.patch Download (2.3 KB) - added by lucian 4 years ago.
Workaround for downloading data URIs to the Journal.
http_check.patch Download (0.8 KB) - added by lucian 4 years ago.
http_check2.patch Download (1.0 KB) - added by lucian 4 years ago.
http_check3.patch Download (1.3 KB) - added by lucian 4 years ago.
improvement in the alert and journal object title

Change History

Changed 4 years ago by lucian

HTML file to reproduce the bug.

Changed 4 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)

Changed 4 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.

Changed 4 years ago by lucian

  • priority changed from Low to Normal
  • status_field changed from New to Assigned

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.

Changed 4 years ago by lucian

Workaround for downloading data URIs to the Journal.

Changed 4 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 4 years ago by lucian

Changed 4 years ago by lucian

Changed 4 years ago by lucian

improvement in the alert and journal object title

Changed 4 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...'

Changed 4 years ago by erikos

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.