Ticket #5504 (closed Bug: fixed)
OpenDocument files shown as garbage text
| Reported by: | stainsby | Owned by: | alecm |
|---|---|---|---|
| Priority: | minor | Milestone: | 2.1.3 |
| Component: | Infrastructure | Version: | |
| Keywords: | Cc: |
Description
When I add an OpenOffice Write (.odt) file, the MIME type is detected correctly as "File type application/vnd.oasis.opendocument.text". However, the page template decides to try to render the contents under "File contents", with garbage text as the result.
The cause is clear: in portal_skins/plone_content/file_view, the decision to display the contents of a file is made by searching for the substring 'text' in the MIME type (OMG!). A quick fix can be hacked in by replacing:
tal:condition="python:test(content_type.find('text')>-1, 1,0)"
with:
tal:condition="python:test(not content_type.startswith('application/vnd.oasis.opendocument.') and (content_type.find('text')>-1), 1,0)"
but that is clearly unsatisfactory for general use.
A possible fix: The mimetype_registry has a boolean "binary' property for each MIME type. I suggest that this should be used.

what about:
content_type.startswith('text') or not mtr.isbinary(content_type)
this should be good enough.