Opened 16 years ago
Last modified 13 years ago
#7076 closed defect
[patch] Treat RTF files with .doc extension as binary — at Initial Version
Reported by: | Owned by: | Jonas Borgström | |
---|---|---|---|
Priority: | high | Milestone: | 0.12.2 |
Component: | attachment | Version: | 0.11-stable |
Severity: | minor | Keywords: | msword, patch |
Cc: | Thijs Triemstra | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
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 theTREAT_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@…>
Note:
See TracTickets
for help on using tickets.