From 82d30e56ef5f54adad654da6daf4b5f372c2be25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 9 Oct 2024 20:20:21 +0200 Subject: [PATCH] Encode JSON value before storing it as date on inbound email Closes #13583 (grafted from bb72b07998cdf71abce85f65427f9adf11c6e022) --HG-- branch : 7.0 --- modules/inbound_email/inbound_email.py | 2 +- modules/inbound_email/tests/test_module.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/inbound_email/inbound_email.py b/modules/inbound_email/inbound_email.py index 9f8cafbc26..f6e5ac04d9 100644 --- a/modules/inbound_email/inbound_email.py +++ b/modules/inbound_email/inbound_email.py @@ -150,7 +150,7 @@ class Email(ModelSQL, ModelView): if event['event'] == 'inbound': emails.append(cls( inbox=inbox, - data=json.dumps(event), + data=json.dumps(event).encode('utf-8'), data_type=data_type)) return emails diff --git a/modules/inbound_email/tests/test_module.py b/modules/inbound_email/tests/test_module.py index 3f1ded5133..56a0f8fa63 100644 --- a/modules/inbound_email/tests/test_module.py +++ b/modules/inbound_email/tests/test_module.py @@ -128,7 +128,7 @@ class InboundEmailTestCase(ModuleTestCase): data = json.dumps({ 'event': 'inbound', 'raw_msg': message.as_string(), - }) + }).encode('utf-8') email = Email(data=data, data_type='mailchimp') self.assertDictEqual(email.as_dict(), self.get_message_dict(message)) @@ -142,7 +142,7 @@ class InboundEmailTestCase(ModuleTestCase): message = self.get_message() data = json.dumps({ 'raw': message.as_string(), - }) + }).encode('utf-8') email = Email(data=data, data_type='mailpace') self.assertDictEqual(email.as_dict(), self.get_message_dict(message)) @@ -179,7 +179,7 @@ class InboundEmailTestCase(ModuleTestCase): 'Name': 'Message-ID', 'Value': '12345@example.com', }], - }) + }).encode('utf-8') email = Email(data=data, data_type='postmark') self.assertDictEqual( @@ -195,7 +195,7 @@ class InboundEmailTestCase(ModuleTestCase): message = self.get_message() data = json.dumps({ 'email': message.as_string(), - }) + }).encode('utf-8') email = Email(data=data, data_type='sendgrid') self.assertDictEqual(email.as_dict(), self.get_message_dict(message))