Misclassifying text as text/html

Bug #143948 reported by Plone Forge
2
Affects Status Importance Assigned to Milestone
Zope 2
Fix Released
Medium
Unassigned

Bug Description

If a text file is uploaded without an extension in the filename,
text_type in lib/python/OFS/content_types.py is called to classify the text as text/html text/xml or text/plain. The very weak condition s.find('</') >= 0 is used for text/html, which means that if you are uploading a bunch of files via WebDAV to a ZWiki, without file extensions, anything with a </ in it gets classified as HTML, hence a Document not a WikiPage under Plone.

The code should be a bit more rigourous: a suggested patch is attached.

Tags: bug zope
Revision history for this message
Plone Forge (ploneforge) wrote :
Revision history for this message
Plone Forge (ploneforge) wrote :

Uploaded: init__.py

Oops - sorry this code has moved in 2.9.8 to
Zope-2.9.8-final/lib/python/zope/app/content_types/__init__.py

The same logic applies as the code was duplicated. Attached is a slightly more elaborate patch that tries to be more efficient.

Revision history for this message
Andreas Jung (ajung) wrote :

Status: Pending => Resolved

Patch applied to 2.10 branch and trunk.

Revision history for this message
Andreas Jung (ajung) wrote :

Status: Resolved => Pending

ups...closed the wrong issue

Revision history for this message
Andreas Jung (ajung) wrote :

Status: Pending => Resolved

Patch applied to the zope.contenttype trunk:

Log message for revision 79688:
  Improved text_type(). Based on the patch from
  http://www.zope.org/Collectors/Zope/2355/

Changed:
  U zope.contenttype/trunk/CHANGES.txt
  U zope.contenttype/trunk/src/zope/contenttype/__init__.py
  U zope.contenttype/trunk/src/zope/contenttype/tests/testContentTypes.py

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.