HTTPResponse too strict with text mime-types

Bug #98411 reported by Andrew Mustun
2
Affects Status Importance Assigned to Milestone
Zope 3
Won't Fix
Medium
Unassigned
zope.publisher
Invalid
Medium
Unassigned

Bug Description

In zope.publisher.http.HTTPResponse:

def _implicitResult(self, body):
    ...
    if not content_type.startswith('text/'):
        raise ValueError(
            'Unicode results must have a text content type.')
    ...
    content_type += ';charset=%s' %encoding
    ...

IMHO, the content type test here is much too strict.
Many mime types don't start with 'text/' and are still text mime types. E.g. application/xml, application/xhtml+xml.

To my best knowledge those mime types can also have a charset parameter appended. E.g. 'application/xml; charset=UTF-8'.

Unfortunately, I couldn't find the reference documentation about that or a definitive list of mime types that can have a charset parameter, so this needs some further research..

Andrew

Revision history for this message
Marius Gedminas (mgedmin) wrote :
Revision history for this message
Gary Poster (gary) wrote :

zope.mimetype keeps track of this information, fwiw. http://svn.zope.org/zope.mimetype/trunk/src/zope/mimetype . It could be used for this kind of check: it keeps track of what mimetypes are encodable.

Changed in zope3:
status: New → Confirmed
Tres Seaver (tseaver)
Changed in zope.publisher:
status: New → Confirmed
importance: Undecided → Medium
Changed in zope3:
status: Confirmed → Won't Fix
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope.publisher project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope.publisher.

Changed in zope.publisher:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.