[issue37461] email.parser.Parser hang

STINNER Victor report at bugs.python.org
Mon Jul 15 05:36:10 EDT 2019


STINNER Victor <vstinner at redhat.com> added the comment:

>>> bytes([0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x78, 0x3b, 0x61, 0x72, 0x1b, 0x2a, 0x3d, 0x22, 0x73, 0x4f, 0x27, 0x23, 0x61, 0xff, 0xff, 0x27, 0x5c, 0x22])
b'Content-Type:x;ar\x1b*="sO\'#a\xff\xff\'\\"'

The following loop of Lib/email/_header_value_parser.py does never stop:

def get_parameter(value):
    """ attribute [section] ["*"] [CFWS] "=" value

    The CFWS is implied by the RFC but not made explicit in the BNF.  This
    simplified form of the BNF from the RFC is made to conform with the RFC BNF
    through some extra checks.  We do it this way because it makes both error
    recovery and working with the resulting parse tree easier.
    """
    ...
    if remainder is not None:
        ...
        while value:
            ...

Attached reproducer.py is code from initial msg346953.

reproducer2.py simplify the input and calls directly get_parameter(). Simplified input string:

   r*="'a'\"

----------
nosy: +vstinner
Added file: https://bugs.python.org/file48483/reproducer.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37461>
_______________________________________


More information about the Python-bugs-list mailing list