ZPublisher setting improper content-type for images
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Won't Fix
|
Undecided
|
Tres Seaver |
Bug Description
An image inside a Plone 4 site is rendered using Collage with an URL
http://
'image' refers to the full-scale version of the image.
Zope delivers the image with content-type text/html
--2011-12-12 16:52:18-- http://
Resolving ise.veit-
Connecting to ise.veit-
HTTP request sent, awaiting response...
HTTP/1.0 200 OK
Server: Zope/(2.12.17, python 2.6.4, linux2) ZServer/1.1
Date: Mon, 12 Dec 2011 15:52:16 GMT
Content-Length: 67856
Content-Type: text/html; charset=utf-8
Connection: Keep-Alive
Set-Cookie: I18N_LANGUAGE="de"; Path=/
Length: 67856 (66K) [text/html]
Some debugging show the culprit within the isHTML() method of the ZPublisher.
112892 tseaver def isHTML(self, s):
112892 tseaver s = s.lstrip()
112892 tseaver # Note that the string can be big, so s.lower(
112892 tseaver # expensive than s[:n].lower().
112892 tseaver if (s[:6].lower() == '<html>' or s[:14].lower() == '<!doctype html'):
112892 tseaver return 1
112892 tseaver if s.find('</') > 0:
112892 tseaver return 1
112892 tseaver return 0
The s.find('</') call returns a value > 0 - obviously the image is containing a byte sequence
matching here.
The 'image' method / view should be setting the content-type header explicitly, instead of relying on ZPublisher to DWIM it.