Edgewall Software

Ticket #7076 (assigned defect)

Opened 8 months ago

Last modified 5 months ago

[patch] Treat RTF files with .doc extension as binary

Reported by: uws@… Owned by: cboos
Priority: normal Milestone: 0.11-retriage
Component: attachment Version: 0.11-stable
Severity: minor Keywords: msword
Cc:

Description

Some .doc files have an application/rdf mime type, e.g. Abiword export-as-doc actually saves a RTF file with a .doc filename. These files are not handled correctly by the Trac MIME viewer, since those RTF files are incorrectly shown as text. The special handling code for RTF (and PostScript and PDF) does not catch this case.

The fix is quite simple:

  • Detect .doc and .dot files as application/msword
  • Add application/msword to the TREAT_AS_BINARY list

Trivial patch below:

--- trac/mimeview/api.py.orig	2008-04-03 23:24:33.000000000 +0200
+++ trac/mimeview/api.py	2008-04-03 23:24:40.000000000 +0200
@@ -76,6 +76,7 @@
     'application/pdf':        ['pdf'],
     'application/postscript': ['ps'],
     'application/rtf':        ['rtf'],
+    'application/msword':     ['doc', 'dot'],
     'application/x-sh':       ['sh'],
     'application/x-csh':      ['csh'],
     'application/x-troff':    ['nroff', 'roff', 'troff'],
@@ -674,7 +675,8 @@
     TREAT_AS_BINARY = [
         'application/pdf',
         'application/postscript',
-        'application/rtf'
+        'application/rtf',
+        'application/msword',
     ]
 
     def get_quality_ratio(self, mimetype):

Please include this in your upcoming releases.

Sincerely,

Wouter Bolsterlee <uws@…>

Attachments

Change History

Changed 8 months ago by cboos

  • status changed from new to assigned
  • severity changed from normal to minor
  • component changed from general to rendering
  • owner changed from jonas to cboos
  • milestone set to 0.11.1
  • keywords msword added

Looks good, thanks.

Changed 5 months ago by Wouter Bolsterlee

Any chance this gets committed any time soon? It's a trivial patch and would help a lot of users (hopefully).

Changed 5 months ago by anonymous

  • version changed from 0.10.4 to 0.11-stable
  • component changed from rendering to attachment

Changed 5 months ago by Wouter Bolsterlee

(Forgot to fill in my name, previous anonymous changes were by me.)

Add/Change #7076 ([patch] Treat RTF files with .doc extension as binary)

Author



Change Properties
<Author field>
Action
as assigned
as The resolution will be set. Next status will be 'closed'
to The owner will change from cboos. Next status will be 'new'
 
Note: See TracTickets for help on using tickets.