Skip to content
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

Fix encoding for utf8 headers 3x #404

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

MrTango
Copy link
Contributor

@MrTango MrTango commented May 16, 2023

Fix encoding problems when using umlauts in from or to headers.

@MrTango MrTango requested a review from petschki May 16, 2023 10:05
@MrTango MrTango changed the base branch from master to 3.x May 16, 2023 10:08
@mauritsvanrees mauritsvanrees merged commit 48eb53d into 3.x Dec 10, 2024
@mauritsvanrees mauritsvanrees deleted the fix_encoding_for_utf8_headers_3x branch December 10, 2024 16:29
@mauritsvanrees
Copy link
Member

LGTM. This may need porting to master as well.

@MrTango
Copy link
Contributor Author

MrTango commented Dec 10, 2024

this is done in #405

@mauritsvanrees
Copy link
Member

I have reverted this, as there are lots of test failures like this:

Error in test test_selectiveFieldMailing (collective.easyform.tests.testMailer.TestFunctions)
Traceback (most recent call last):
  File "/Users/maurits/.pyenv/versions/3.8.20/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
    yield
  File "/Users/maurits/.pyenv/versions/3.8.20/lib/python3.8/unittest/case.py", line 676, in run
    self._callTestMethod(testMethod)
  File "/Users/maurits/.pyenv/versions/3.8.20/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
    method()
  File "/Users/maurits/community/collective.easyform-3x/src/collective/easyform/tests/testMailer.py", line 381, in test_selectiveFieldMailing
    mailer.onSuccess(fields, request)
  File "/Users/maurits/community/collective.easyform-3x/src/collective/easyform/actions.py", line 519, in onSuccess
    mailtext = self.get_mail_text(fields, request, context)
  File "/Users/maurits/community/collective.easyform-3x/src/collective/easyform/actions.py", line 514, in get_mail_text
    return outer.as_string()
  File "/Users/maurits/.pyenv/versions/3.8.20/lib/python3.8/email/message.py", line 158, in as_string
    g.flatten(self, unixfrom=unixfrom)
  File "/Users/maurits/.pyenv/versions/3.8.20/lib/python3.8/email/generator.py", line 118, in flatten
    self._write(msg)
  File "/Users/maurits/.pyenv/versions/3.8.20/lib/python3.8/email/generator.py", line 201, in _write
    self._write_headers(msg)
  File "/Users/maurits/.pyenv/versions/3.8.20/lib/python3.8/email/generator.py", line 228, in _write_headers
    folded = self.policy.fold(h, v)
  File "/Users/maurits/.pyenv/versions/3.8.20/lib/python3.8/email/_policybase.py", line 334, in fold
    return self._fold(name, value, sanitize=True)
  File "/Users/maurits/.pyenv/versions/3.8.20/lib/python3.8/email/_policybase.py", line 377, in _fold
    parts.append(h.encode(linesep=self.linesep, maxlinelen=maxlinelen))
AttributeError: 'bytes' object has no attribute 'encode'

I wonder if your fix is only needed on Python 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants