Title: gh-142006: Fix HeaderWriteError in email.policy.default caused by extra newline by pareshjoshij · Pull Request #142008 · python/cpython · GitHub
Open Graph Title: gh-142006: Fix HeaderWriteError in email.policy.default caused by extra newline by pareshjoshij · Pull Request #142008 · python/cpython
X Title: gh-142006: Fix HeaderWriteError in email.policy.default caused by extra newline by pareshjoshij · Pull Request #142008 · python/cpython
Description: Description This PR fixes gh-142006 where email.policy.default would raise a HeaderWriteError when folding certain long address headers. The Issue: In _header_value_parser.py, the function _steal_trailing_WSP_if_exists moves trailing whitespace from the previous line to the current one. However, if the previous line contained only that whitespace, it was left as an empty string ''. When joined, this resulted in a double newline (\n\n), which is illegal in headers and triggered the error. The Fix: Modified _steal_trailing_WSP_if_exists to remove the line entirely (lines.pop()) if it becomes empty after stealing the whitespace. Verification: Added a regression test test_fold_address_list_with_stolen_whitespace to Lib/test/test_email/test_policy.py which reproduces the reported crash and verifies the fix. Linked Issue Fixes gh-142006
Open Graph Description: Description This PR fixes gh-142006 where email.policy.default would raise a HeaderWriteError when folding certain long address headers. The Issue: In _header_value_parser.py, the function _steal_t...
X Description: Description This PR fixes gh-142006 where email.policy.default would raise a HeaderWriteError when folding certain long address headers. The Issue: In _header_value_parser.py, the function _steal_t...
Opengraph URL: https://github.com/python/cpython/pull/142008
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:b59e3fc6-0516-d232-2439-eb6da08f02ba |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8AAE:3AE31F:61B7706:8077E63:696DB8B1 |
| html-safe-nonce | b2f85226a886f7f5b99fdccbcc5edbc54c4069de74ec86c47bca6c8db9156286 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QUFFOjNBRTMxRjo2MUI3NzA2OjgwNzdFNjM6Njk2REI4QjEiLCJ2aXNpdG9yX2lkIjoiMjU1OTE5MzA4ODg3OTMxMDU3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 16f2c1e16a60dd8cc33c3d98b5a29e7e83f167ed1cc39259df278e75fb68f245 |
| hovercard-subject-tag | pull_request:3050476249 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/python/cpython/pull/142008/files |
| twitter:image | https://avatars.githubusercontent.com/u/194076591?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/194076591?s=400&v=4 |
| og:image:alt | Description This PR fixes gh-142006 where email.policy.default would raise a HeaderWriteError when folding certain long address headers. The Issue: In _header_value_parser.py, the function _steal_t... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7e5ae23c70136152637ceee8d6faceb35596ec46 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width