- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | r.david.murray |
|---|---|
| Recipients | barry, era, mjpieters, r.david.murray |
| Date | 2018-12-21.17:49:58 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1545414599.16.0.857683086682.issue35547@roundup.psfhosted.org> |
| In-reply-to |
| Content |
|---|
Here's a patch that makes the example work correctly. This is not a fix, a real fix will be more complicated. This just demonstrates the kind of thing that needs fixing and where.
The existing parser produces a sub-optimal parse tree as its result...the parse tree is hard to inspect and manipulate because there are so many special cases. A good fix here would create some sort of function that could be passed an existing TokenList, the new token to add to that list, and the function would check all the special cases and do the EWWhiteSpaceTerminal substitution when and as appropriate. This could then be used in the unstructured parser as well as Phrase...and some thought should be given to where else it might be needed. It has been long enough since I've held the RFCs in my head that I don't remember if there is anywhere else.
I haven't looked at the actual character string, so I don't know if we need to also be detecting and posting a defect about a split character or not, but we don't *have* to answer that question to fix this.
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index e805a75..d5d5986 100644
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -199,6 +199,10 @@ class CFWSList(WhiteSpaceTokenList):
class Atom(TokenList):
+ @property
+ def has_encoded_word(self):
+ return any(t.token_type=='encoded-word' for t in self)
+
token_type = 'atom'
@@ -1382,6 +1386,12 @@ def get_phrase(value):
"comment found without atom"))
else:
raise
+ if token.has_encoded_word:
+ assert phrase[-1].token_type == 'atom', phrase[-1]
+ assert phrase[-1][-1].token_type == 'cfws'
+ assert phrase[-1][-1][-1].token_type == 'fws'
+ if phrase[-1].has_encoded_word:
+ phrase[-1][-1] = EWWhiteSpaceTerminal(phrase[-1][-1][-1], 'fws')
phrase.append(token)
return phrase, value |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2018-12-21 17:50:00 | r.david.murray | set | recipients: + r.david.murray, barry, mjpieters, era |
| 2018-12-21 17:49:59 | r.david.murray | set | messageid: <1545414599.16.0.857683086682.issue35547@roundup.psfhosted.org> |
| 2018-12-21 17:49:59 | r.david.murray | link | issue35547 messages |
| 2018-12-21 17:49:58 | r.david.murray | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements
