8000 gh-134155: fix AttributeError in email._header_value_parser.get_address by sergey-miryanov · Pull Request #134194 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
/ cpython Public

gh-134155: fix AttributeError in email._header_value_parser.get_address #134194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix handling of empty strings in .get_dtext, .get_qp_ctext and .get_q…
…content
  • Loading branch information
sergey-miryanov committed May 18, 2025
commit 5c3fa1140ef5115d504d4a35fa810e403a6b61eb
1 change: 1 addition & 0 deletions Lib/email/_header_value_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ def _get_ptext_to_endchars(value, endchars):
vchars = []
escape = False
had_qp = False
pos = 0
for pos in range(len(fragment)):
if fragment[pos] == '\\':
if escape:
Expand Down
9 changes: 9 additions & 0 deletions Lib/test/test_email/test__header_value_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ def test_get_qp_ctext_non_printables(self):
[errors.NonPrintableDefect], ')')
self.assertEqual(ptext.defects[0].non_printables[0], '\x00')

def test_get_qp_ctext_empty(self):
self._test_get_x(parser.get_qp_ctext, '', '', ' ', [], '')

# get_qcontent

def test_get_qcontent_only(self):
Expand Down Expand Up @@ -503,6 +506,9 @@ def test_get_qcontent_non_printables(self):
[errors.NonPrintableDefect], '"')
self.assertEqual(ptext.defects[0].non_printables[0], '\x00')

def test_get_qcontent_empty(self):
self._test_get_x(parser.get_qcontent, '', '', '', [], '')

# get_atext

def test_get_atext_only(self):
Expand Down Expand Up @@ -1283,6 +1289,9 @@ def test_get_dtext_open_bracket_mid_word(self):
self._test_get_x(parser.get_dtext,
'foo[bar', 'foo', 'foo', [], '[bar')

def test_get_dtext_empty(self):
self._test_get_x(parser.get_dtext, '', '', '', [], '')

# get_domain_literal

def test_get_domain_literal_only(self):
Expand Down
0