Skip to content

Fix encoding for utf8 headers 3x - #404

Merged
mauritsvanrees merged 1 commit into
3.xfrom
fix_encoding_for_utf8_headers_3x
Dec 10, 2024
Merged

Fix encoding for utf8 headers 3x#404
mauritsvanrees merged 1 commit into
3.xfrom
fix_encoding_for_utf8_headers_3x

Conversation

@MrTango

@MrTango MrTango commented May 16, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

LGTM. This may need porting to master as well.

@MrTango

MrTango commented Dec 10, 2024

Copy link
Copy Markdown
Contributor Author

this is done in #405

@mauritsvanrees

Copy link
Copy Markdown
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