[New-bugs-announce] [issue37491] IndexError in get_bare_quoted_string
Abhilash Raj
report at bugs.python.org
Wed Jul 3 04:19:31 EDT 2019
New submission from Abhilash Raj <raj.abhilash1 at gmail.com>:
from email.parser import BytesParser, Parser
from email.policy import default
payload = 'Content-Type:x;\x1b*="\'G\'\\"""""'
msg = Parser(policy=default).parsestr(payload)
print(msg.get('content-type'))
When trying to review PR for BPO 37461, I found another bug where an IndexError
is raised if there aren't closing quote characters in the input message:
Suggested patch:
@@ -1191,7 +1192,7 @@ def get_bare_quoted_string(value):
"expected '\"' but found '{}'".format(value))
bare_quoted_string = BareQuotedString()
value = value[1:]
- if value[0] == '"':
+ if value and value[0] == '"':
token, value = get_qcontent(value)
bare_quoted_string.append(token)
while value and value[0] != '"':
----------
components: email
messages: 347190
nosy: barry, maxking, r.david.murray
priority: normal
severity: normal
status: open
title: IndexError in get_bare_quoted_string
type: crash
versions: Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37491>
_______________________________________
More information about the New-bugs-announce
mailing list