Title: UnstructuredHeader drops encoded-word Base64 padding defects · Issue #158780 · python/cpython · GitHub
Open Graph Title: UnstructuredHeader drops encoded-word Base64 padding defects · Issue #158780 · python/cpython
X Title: UnstructuredHeader drops encoded-word Base64 padding defects · Issue #158780 · python/cpython
Description: Bug report Bug description: Documented behaviour: BaseHeader documentation in email.headerregistry: "Defects should be added to the list instead. The standard header parsers register defects for RFC compliance issues, for obsolete RFC sy...
Open Graph Description: Bug report Bug description: Documented behaviour: BaseHeader documentation in email.headerregistry: "Defects should be added to the list instead. The standard header parsers register defects for RF...
X Description: Bug report Bug description: Documented behaviour: BaseHeader documentation in email.headerregistry: "Defects should be added to the list instead. The standard header parsers register defects f...
Opengraph URL: https://github.com/python/cpython/issues/158780
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"UnstructuredHeader drops encoded-word Base64 padding defects","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\n**Documented behaviour:** BaseHeader documentation in email.headerregistry: \"Defects should be added to the list instead. The standard header parsers register defects for RFC compliance issues, for obsolete RFC syntax, and for unrecoverable parsing errors.\"\r\n\r\n**Expected:** The Subject header's defects includes InvalidBase64PaddingDefect.\r\n\r\n**Actual:** The parser's all_defects includes InvalidBase64PaddingDefect, but the Subject header's defects does not.\r\n\r\n```python\r\nfrom email.headerregistry import HeaderRegistry, UnstructuredHeader\r\nfrom email.errors import InvalidBase64PaddingDefect\r\n\r\nvalue = '=?utf-8?b?YQ?='\r\nif not value.isascii() or '\\r' in value or '\\n' in value:\r\n print('REFUTATION REJECTED: input is not unfolded ASCII')\r\nelse:\r\n expected = any(isinstance(d, InvalidBase64PaddingDefect)\r\n for d in UnstructuredHeader.value_parser(value).all_defects)\r\n actual = any(isinstance(d, InvalidBase64PaddingDefect)\r\n for d in HeaderRegistry()('Subject', value).defects)\r\n if expected and not actual:\r\n print('REFUTATION CONFIRMED:', repr(value),\r\n 'actual:', actual, 'expected:', expected)\r\n else:\r\n print('REFUTATION REJECTED: parser prerequisite absent or defect preserved',\r\n repr(value), 'actual:', actual, 'expected:', expected)\r\n```\r\n\r\nOutput on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library `email.headerregistry`:\r\n\r\n```\r\nREFUTATION CONFIRMED: '=?utf-8?b?YQ?=' actual: False expected: True\r\n```\r\n\r\nThis report was found and written by an automated property-testing tool I run ([bugforge](https://github.com/augusto-rehfeldt/bugforge)). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/email.headerregistry-20261003-021509-c2\r\n\r\n### CPython versions tested on:\r\n\r\n3.14\r\n\r\n### Operating systems tested on:\r\n\r\nWindows\r\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-160862\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/augusto-rehfeldt","@type":"Person","name":"augusto-rehfeldt"},"datePublished":"2026-10-04T01:07:54Z","url":"https://github.com/python/cpython/issues/158780"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:aadc937f-96d9-8859-882f-81e0ea8b684b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 80BA:3DCD28:1A789C2:2306029:6B021B6D |
| html-safe-nonce | 935325eae45a5389f02c64a3b10598859d60c800640f80a1839789108958ede1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEJBOjNEQ0QyODoxQTc4OUMyOjIzMDYwMjk6NkIwMjFCNkQiLCJ2aXNpdG9yX2lkIjoiMjQ3OTUzMTM3MjQ5NTExNzE2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ea9fecd610b14b3dc12b5a06c6233d831af35d8b964dec954a10a5fc29fa1f4f |
| hovercard-subject-tag | issue:5695114054 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/158780/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ea55e1b3a1cd657e28c0e13f3a5492140ebde692b7621cf03620ace210c34590/python/cpython/issues/158780 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ea55e1b3a1cd657e28c0e13f3a5492140ebde692b7621cf03620ace210c34590/python/cpython/issues/158780 |
| og:image:alt | Bug report Bug description: Documented behaviour: BaseHeader documentation in email.headerregistry: "Defects should be added to the list instead. The standard header parsers register defects for RF... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | augusto-rehfeldt |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width