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 issues when using umlauts in from/to headers #405

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MrTango
Copy link
Contributor

@MrTango MrTango commented May 16, 2023

No description provided.

@MrTango MrTango requested a review from petschki May 16, 2023 10:07
Copy link
Member

@petschki petschki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use plone.base.utils.safe_bytes instead.

And the import at the top should be changed to plone.base.utils.safe_text

@MrTango MrTango force-pushed the fix_encoding_for_utf8_headers branch 3 times, most recently from b2654ad to db6dbf0 Compare May 16, 2023 10:46
Copy link
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@mauritsvanrees mauritsvanrees dismissed petschki’s stale review July 27, 2023 15:17

Requested changes have been made.

@mauritsvanrees mauritsvanrees force-pushed the fix_encoding_for_utf8_headers branch from db6dbf0 to c858d53 Compare July 27, 2023 15:19
@mauritsvanrees
Copy link
Member

I rebased on master and force-pushed.

@mauritsvanrees
Copy link
Member

Lots of test failures like this:

AttributeError: 'bytes' object has no attribute 'encode'

@mauritsvanrees
Copy link
Member

@MrTango I don't know why no tests show up here. But locally lots of tests fail like this:

Error in test testMultiRecipientOverrideByString (collective.easyform.tests.testMailer.TestFunctions.testMultiRecipientOverrideByString)
Traceback (most recent call last):
  File "/Users/maurits/.pyenv/versions/3.11.11/lib/python3.11/unittest/case.py", line 57, in testPartExecutor
    yield
  File "/Users/maurits/.pyenv/versions/3.11.11/lib/python3.11/unittest/case.py", line 623, in run
    self._callTestMethod(testMethod)
  File "/Users/maurits/.pyenv/versions/3.11.11/lib/python3.11/unittest/case.py", line 579, in _callTestMethod
    if method() is not None:
  File "/Users/maurits/community/collective.easyform/src/collective/easyform/tests/testMailer.py", line 380, in testMultiRecipientOverrideByString
    mailer.onSuccess(data, request)
  File "/Users/maurits/community/collective.easyform/src/collective/easyform/actions.py", line 553, in onSuccess
    mailtext = self.get_mail_text(fields, request, context)
  File "/Users/maurits/community/collective.easyform/src/collective/easyform/actions.py", line 548, in get_mail_text
    return outer.as_string()
  File "/Users/maurits/.pyenv/versions/3.11.11/lib/python3.11/email/message.py", line 188, in as_string
    g.flatten(self, unixfrom=unixfrom)
  File "/Users/maurits/.pyenv/versions/3.11.11/lib/python3.11/email/generator.py", line 117, in flatten
    self._write(msg)
  File "/Users/maurits/.pyenv/versions/3.11.11/lib/python3.11/email/generator.py", line 200, in _write
    self._write_headers(msg)
  File "/Users/maurits/.pyenv/versions/3.11.11/lib/python3.11/email/generator.py", line 227, in _write_headers
    folded = self.policy.fold(h, v)
  File "/Users/maurits/.pyenv/versions/3.11.11/lib/python3.11/email/_policybase.py", line 334, in fold
    return self._fold(name, value, sanitize=True)
  File "/Users/maurits/.pyenv/versions/3.11.11/lib/python3.11/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 on Python 3 these headers need to be passed in as strings (text) anyway now...

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.

3 participants