Opened 15 years ago

Closed 15 years ago

Last modified 11 years ago

#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:

  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 (5)

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

Download all attachments as: .zip

Change History (12)

Changed 15 years ago by lucian

HTML file to reproduce the bug.

comment:1 Changed 15 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 15 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 15 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.

Changed 15 years ago by lucian

Workaround for downloading data URIs to the Journal.

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

Changed 15 years ago by lucian

Changed 15 years ago by lucian

improvement in the alert and journal object title

comment:5 Changed 15 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:7 Changed 11 years ago by dnarvaez

  • Milestone 0.86 deleted

Milestone 0.86 deleted

Note: See TracTickets for help on using tickets.