Ticket #541 (closed defect: fixed)

Opened 4 years ago

Last modified 12 days ago

Mime type mess with files downloaded with Browse

Reported by: sayamindu Owned by: erikos
Priority: Unspecified by Maintainer Milestone:
Component: Browse Version: 0.82.x
Severity: Blocker Keywords:
Cc: tomeu, sascha_silbe Distribution/OS: Unspecified
Bug Status: Unconfirmed

Description

Files which are normally zip files (eg: Open Document files, Epub files, etc) seem to have the extension set to application/x-zip in the datastore. Steps to reproduce

1. Open Browse and navigate to  http://feedbooks.com/book/102

2. Download the epub file linked from that page

3. Try to open the file from the journal (you can have a mock activity which has the mimetype for application/epub+zip registered)

4. View the log for Journal: it contains a line which says:

WARNING root: No activity can open this object, application/x-zip.

This normally occurs when the extension of the file is truncated, which means that there is no way to distinguish the file from a normal zip file.

I have seen this occur on Sucrose 0.82, on XO OS build 767

Attachments

mimetypes.xml Download (273 bytes) - added by sayamindu 4 years ago.
As per discussion on IRC, I also included a mimetype.xml file in my activity. It did not seem to fix the problem
browse_save_with_extension.patch Download (1.7 KB) - added by sayamindu 4 years ago.
This hack seems to solve the issue.

Change History

Changed 4 years ago by sayamindu

As per discussion on IRC, I also included a mimetype.xml file in my activity. It did not seem to fix the problem

Changed 4 years ago by sayamindu

This hack seems to solve the issue.

Changed 4 years ago by tomeu

  • severity changed from Major to Blocker

Changed 4 years ago by erikos

  • milestone changed from Unspecified by Release Team to 0.84

Changed 4 years ago by tomeu

Would this patch help with zip-based file types? I would prefer not discarding always the mime type sent by the server because many webapps would break that way.

diff --git a/downloadmanager.py b/downloadmanager.py
index e41d06f..69d1c8a 100644
--- a/downloadmanager.py
+++ b/downloadmanager.py
@@ -180,7 +180,8 @@ class Download:
             self.dl_jobject.metadata['progress'] = '100'
             self.dl_jobject.file_path = self._target_file.path
 
-            if self._mime_type == 'application/octet-stream':
+            if self._mime_type in ['application/octet-stream',
+                                   'application/x-zip']:
                 sniffed_mime_type = mime.get_for_file(self._target_file.path)
                 self.dl_jobject.metadata['mime_type'] = sniffed_mime_type
 

Changed 4 years ago by tomeu

Also, you may want to add an icon and a parent mime type. From the odt file:

  <sub-class-of type="application/zip"/>
  <generic-icon name="x-office-document"/>

Changed 4 years ago by sascha_silbe

  • cc sascha_silbe added

Changed 4 years ago by tomeu

  • status changed from new to closed
  • resolution set to fixed

Changed 12 days ago by godiard

  • milestone 0.84 deleted

Milestone 0.84 deleted

Note: See TracTickets for help on using tickets.