text_type can give IndexError: string index out of range in zope 2.11 & 2.12
Bug #487998 reported by
Simon Michael
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Reporting for Justin Dunsworth:
<sm> The fix for https:/
<sm> http://
<sm> to reproduce, have a dtml document return whitespace greater than 14 chars in length
To post a comment you must log in.
In case the gist disappears:
def text_type(s):
"""Given an unnamed piece of text, try to guess its content type.
Detects HTML, XML, and plain text. Returns a MIME type string
such as 'text/html'.
"""
# at least the maximum length of any tags we look for
iMAXLEN=14
if len(s) < iMAXLEN: return 'text/plain'
i = 0
while s[i] in string.whitespace: # <- bug
i += 1 # <-