Commit 92f2197f authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

testInterfacePost: ignore the difference of Message-ID header format on zope5py3.

parent 16ae0387
Pipeline #33339 failed with stage
in 0 seconds
......@@ -247,7 +247,7 @@ class TestInterfacePost(ERP5TypeTestCase):
last_message, = self.portal.MailHost._message_list
self.assertNotEqual((), last_message)
_, _, message_text = last_message
self.assertIn(message_text, sequence['internet_message_post'].getData())
self.assertIn(message_text.replace(b'Message-ID: \n ', b'Message-ID: '), sequence['internet_message_post'].getData())
def _getMailHostMessageForRecipient(self, recipient_email_address):
message_list = self.portal.MailHost._message_list
......@@ -268,7 +268,7 @@ class TestInterfacePost(ERP5TypeTestCase):
self.assertEqual(len(message_list), 1)
message = message_list[0]
_, _, message_text = message
self.assertIn(message_text, post.getData())
self.assertIn(message_text.replace(b'Message-ID: \n ', b'Message-ID: '), post.getData())
def stepCheckMailMessagePreviewDisplaysLatestInternetMessagePostData(self, sequence=None, sequence_list=None):
mail_message = sequence['mail_message']
......
  • I thought that this was a bug, but according to https://datatracker.ietf.org/doc/html/rfc5322#section-2.2.3 it might be OK. Is that also your understanding ? if yes, maybe we can add a reference to that ?

  • mmh but still, it looks like a bug somewhere, if it's equivalent to have \n in the serialized message, then isn't the parser supposed to remove the extra \n ? I investigated a bit some days ago, these were my notes:

    import email
    
    mb = (
      b'Content-Type: multipart/mixed; boundary="===============boundary=="\n'
      b'Message-ID: <170831831588.80413.17161314261293097219.17161314261293097219@example.com>\n'
      b'--===============boundary==--'
    )
    
    m = email.message_from_bytes(mb)
    
    print(repr(m.get('Message-ID')))
    # OK '<170831831588.80413.17161314261293097219.17161314261293097219@example.com>'
    
    m_from_bytes = email.message_from_bytes(m.as_bytes())
    print(repr(m_from_bytes.get('Message-ID')))
    # NOT OK '\n <170831831588.80413.17161314261293097219.17161314261293097219@example.com>'
    
    
    # note that when using str it is OK:
    m_from_str = email.message_from_string(m.as_string())
    print(repr(m_from_str.get('Message-ID')))
    # OK '<170831831588.80413.17161314261293097219.17161314261293097219@example.com>'
    
    
    # already different here:
    print(repr(m.as_bytes()))
    print(repr(m.as_string()))
    
    # the output is controlled by max_header_length of the `policy` argument.
    # not sure if the problem is when emitting the email or parsing it
    
  • mentioned in commit f420d177

    Toggle commit list
  • mentioned in commit 03fe47d3

    Toggle commit list
  • mentioned in commit 6b2c1ed9

    Toggle commit list
  • mentioned in commit be2db749

    Toggle commit list
  • mentioned in commit 8813fa46

    Toggle commit list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment