Ticket #7076 (assigned defect)
[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
Note: See
TracTickets for help on using
tickets.


