Fix IndexError when parsing unexpectedly ending quoted-string. (GH-14813)
This exception was caused because the input ended unexpectedly with only one
single quote instead of a pair with some value inside it.
(cherry picked from commit 719a062bcb
)
Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
This commit is contained in:
parent
6816ca30af
commit
635743355d
|
@ -1170,7 +1170,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] != '"':
|
||||
|
|
|
@ -503,6 +503,10 @@ class TestParser(TestParserMixin, TestEmailBase):
|
|||
self._test_get_x(parser.get_bare_quoted_string,
|
||||
'""', '""', '', [], '')
|
||||
|
||||
def test_get_bare_quoted_string_missing_endquotes(self):
|
||||
self._test_get_x(parser.get_bare_quoted_string,
|
||||
'"', '""', '', [errors.InvalidHeaderDefect], '')
|
||||
|
||||
def test_get_bare_quoted_string_following_wsp_preserved(self):
|
||||
self._test_get_x(parser.get_bare_quoted_string,
|
||||
'"foo"\t bar', '"foo"', 'foo', [], '\t bar')
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fix ``IndexError`` when parsing email headers with unexpectedly ending
|
||||
bare-quoted string value. Patch by Abhilash Raj.
|
Loading…
Reference in New Issue