-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-75171: Fix parsing address headers with dots start/end display name #2811
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
Conversation
|
@timb07, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bitdancer, @ezio-melotti and @serhiy-storchaka to be potential reviewers. |
|
|
||
| def test_complex_address_list(self): | ||
| examples = list(self.example_params.values()) | ||
| examples = list(self.example_params.values())[:-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not future proof. What if someone adds new tests? In fact, you are just hidding that name_starting_with_dot is not passing the test:
ERROR: test_complex_address_list (test.test_email.test_headerregistry.TestAddressHeader)
----------------------------------------------------------------------
Traceback (most recent call last):
File "Lib/email/_header_value_parser.py", line 1907, in get_address
token, value = get_group(value)
File "Lib/email/_header_value_parser.py", line 1866, in get_group
"display name but found '{}'".format(value))
email.errors.HeaderParseError: expected ':' at end of group display name but found '<jxd@example.com>'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Lib/test/test_email/test_headerregistry.py", line 1284, in test_complex_address_list
h = self.make_header('to', source)
File "Lib/test/test_email/test_headerregistry.py", line 78, in make_header
return self.factory(name, value)
File "Lib/email/headerregistry.py", line 589, in __call__
return self[name](name, value)
File "Lib/email/headerregistry.py", line 197, in __new__
cls.parse(value, kwds)
File "Lib/email/headerregistry.py", line 340, in parse
kwds['parse_tree'] = address_list = cls.value_parser(value)
File "Lib/email/headerregistry.py", line 331, in value_parser
address_list, value = parser.get_address_list(value)
File "Lib/email/_header_value_parser.py", line 1930, in get_address_list
token, value = get_address(value)
File "Lib/email/_header_value_parser.py", line 1910, in get_address
token, value = get_mailbox(value)
File "Lib/email/_header_value_parser.py", line 1733, in get_mailbox
token, value = get_name_addr(value)
File "Lib/email/_header_value_parser.py", line 1716, in get_name_addr
token[0][:0] = [leader]
TypeError: 'ValueTerminal' object does not support item assignment
I think you should try to fix this one too :)
|
Thanks for the patch! Could you add the NEWs entry as well please? |
|
This PR is stale because it has been open for 30 days with no activity. |
|
This PR is stale because it has been open for 30 days with no activity. |
|
@timb07 This abandoned PR will be closed in a few weeks if the reviews will not be addressed or at least commented. |
|
OP did not allow to push into the PR branch do I can neither try to fix the PR nor even use the web interface to merge @timb07 Could you address the review please? It would be great to see this PR merged. |
|
For the NEWS entry, you can create the following |
|
@timb07 You can ping me to reopen this pull request if/when you want to continue your work here. Closing as abandoned and unrecoverable: |

In
email._header_value_parser.DisplayName(), ensure we're dealing with aTokenListbefore trying to access itstoken_typeattribute. This scenario is encountered when parsing a display name starting with a dot (".") or ending with a dot and without whitespace separating it from the angle bracket starting the address.Add tests to confirm.
https://bugs.python.org/issue30988