ZPublisher setting improper content-type for images

Bug #903251 reported by Andreas Jung
6
This bug affects 1 person
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://zopyx.com:31240/ise/de/Leistungsangebot_tcm74002.jpg/image

'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://ise.veit-schiele.de:31240/ise/de/Leistungsangebot_tcm74002.jpg/image
Resolving ise.veit-schiele.de... 83.223.91.163
Connecting to ise.veit-schiele.de|83.223.91.163|:31240... connected.
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().startswith() is more
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.

Revision history for this message
Tres Seaver (tseaver) wrote :

The 'image' method / view should be setting the content-type header explicitly, instead of relying on ZPublisher to DWIM it.

Changed in zope2:
assignee: nobody → Tres Seaver (tseaver)
status: New → Won't Fix
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.