mirror of
https://github.com/python/cpython.git
synced 2025-10-07 07:31:46 +00:00
bpo-32178: Fix IndexError trying to parse 'To' header starting with ':'. (GH-15044)
This should fix the IndexError trying to retrieve `DisplayName.display_name` and `DisplayName.value` when the `value` is basically an empty string. https://bugs.python.org/issue32178
This commit is contained in:
parent
51aac15f6d
commit
09a1872a80
3 changed files with 12 additions and 1 deletions
|
@ -561,6 +561,8 @@ class DisplayName(Phrase):
|
|||
@property
|
||||
def display_name(self):
|
||||
res = TokenList(self)
|
||||
if len(res) == 0:
|
||||
return res.value
|
||||
if res[0].token_type == 'cfws':
|
||||
res.pop(0)
|
||||
else:
|
||||
|
@ -582,7 +584,7 @@ class DisplayName(Phrase):
|
|||
for x in self:
|
||||
if x.token_type == 'quoted-string':
|
||||
quote = True
|
||||
if quote:
|
||||
if len(self) != 0 and quote:
|
||||
pre = post = ''
|
||||
if self[0].token_type=='cfws' or self[0][0].token_type=='cfws':
|
||||
pre = ' '
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue