[zope2-tracker] [Bug 487998] Re: text_type can give IndexError: string index out of range in zope 2.11 & 2.12

Simon Michael simon at joyful.com
Tue Nov 24 23:53:49 EST 2009


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                                                        # <-

-- 
text_type can give IndexError: string index out of range in zope 2.11 & 2.12
https://bugs.launchpad.net/bugs/487998
You received this bug notification because you are a member of Zope 2
Developers, which is subscribed to Zope 2.


More information about the zope2-tracker mailing list