[issue29412] IndexError thrown on email.message.Message.get

Abhilash Raj report at bugs.python.org
Fri Jun 14 15:07:13 EDT 2019


Abhilash Raj <raj.abhilash1 at gmail.com> added the comment:

Nevermind, I was wrong, I was able to reproduce it:

>>> msg = email.message_from_string('To: (Recipient list suppressed)', policy=email.policy.default))
  File "<stdin>", line 1
SyntaxError: unmatched ')'
>>> msg = email.message_from_string('To: (Recipient list suppressed)', policy=email.policy.default)
>>> msg.get('to')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/maxking/Documents/cpython/Lib/email/message.py", line 471, in get
    return self.policy.header_fetch_parse(k, v)
  File "/home/maxking/Documents/cpython/Lib/email/policy.py", line 163, in header_fetch_parse
    return self.header_factory(name, value)
  File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 589, in __call__
    return self[name](name, value)
  File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 197, in __new__
    cls.parse(value, kwds)
  File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 340, in parse
    kwds['parse_tree'] = address_list = cls.value_parser(value)
  File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 331, in value_parser
    address_list, value = parser.get_address_list(value)
  File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1951, in get_address_list
    token, value = get_address(value)
  File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1928, in get_address
    token, value = get_group(value)
  File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1884, in get_group
    token, value = get_display_name(value)
  File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1710, in get_display_name
    token, value = get_phrase(value)
  File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1385, in get_phrase
    token, value = get_word(value)
  File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1360, in get_word
    if value[0]=='"':
IndexError: string index out of range

----------

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


More information about the Python-bugs-list mailing list