Nasreddin Boulif (bon)
c78edec4d5
[FIX] mail_thread: save attachment from mail in same encoding
...
Steps to reproduce:
- Configure incoming mail server and set it to create X record
on incoming mails (X can be any model with a chatter)
- Create a CSV file and set the encoding to UTF-16
- Send the CSV file through Gmail to the Odoo instance
- Go to model X and open the created record
- In the chatter, click/download the CSV file
- Open the downloaded file with Geany (or any file editor that can
show the file encoding)
Issue:
The file encoding is not the same as the original file (utf-8 instead
of utf-16).
Working with Outlook.
Cause:
The difference between Outlook and Gmail is that Gmail provides the
charset of the file.
The content of the mail is retrieved using `email` python lib.
The lib will try to retrieve the charset of the file and fallback
on `ASCII` if not available, then return the decode content.
```python
def get_text_content(msg, errors='replace'):
content = msg.get_payload(decode=True)
charset = msg.get_param('charset', 'ASCII')
return content.decode(charset, errors=errors)
```
Example:
content = b'd\x00a\x00,\x00,\x00,\......'
Outlook:
charset = 'ASCII'
return => 'd\x00a\x00,\x00,\x00...'
Gmail:
charset = 'UTF-16LE'
return => 'da,,,,,\n,,,,,\....'
In the post process of the attachment, the content is encoded in
'utf-8' (to then encoded in base64) before creating the attachment
record.
Content encoded to 'utf-8':
Outlook: b'd\x00a\x00,\x00,\x00...'
Gmail: b'da,,,,,\n,,,,,\n....'
Therefore, when writing the file on the disk, the encoding is based
on the binary content.
Solution:
When parsing the mail, add the encoding charset to the `info` variable.
Then, when creating the attachment, use the charset in `info` (or
fallback on 'utf'8' if no charset set) to encode the content.
opw-3089009
closes odoo/odoo#118694
X-original-commit: 2d1b13e68d8bb204ecfe12a9d3db519c4264592c
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com >
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com >
2023-04-17 15:18:54 +02:00
..
2023-04-16 09:49:06 +02:00
2023-04-06 18:18:06 +02:00
2023-04-13 16:39:48 +02:00
2023-04-17 11:46:47 +02:00
2023-03-18 03:32:40 +01:00
2023-04-17 11:46:47 +02:00
2023-04-13 16:39:48 +02:00
2023-04-13 16:39:48 +02:00
2023-03-31 11:58:47 +02:00
2023-03-20 16:51:30 +01:00
2023-03-24 12:50:13 +01:00
2023-04-05 20:03:09 +02:00
2023-03-20 16:51:30 +01:00
2023-03-20 16:51:30 +01:00
2023-03-08 11:37:07 +01:00
2023-04-13 16:40:11 +02:00
2023-04-03 17:07:24 +02:00
2023-04-04 13:35:18 +02:00
2023-04-03 17:07:24 +02:00
2023-03-07 11:11:51 +01:00
2023-04-03 17:07:24 +02:00
2023-04-09 08:03:45 +02:00
2023-04-03 17:07:24 +02:00
2023-03-20 16:51:30 +01:00
2023-03-30 16:22:51 +02:00
2023-03-20 16:51:30 +01:00
2023-03-20 16:51:30 +01:00
2023-04-13 04:08:50 +02:00
2023-03-20 16:51:30 +01:00
2023-03-14 15:52:10 +01:00
2023-04-13 12:29:51 +02:00
2023-03-20 16:51:30 +01:00
2023-03-28 18:45:47 +02:00
2023-04-13 17:57:13 +02:00
2023-04-07 21:48:48 +02:00
2023-04-14 18:43:34 +02:00
2023-03-20 16:51:30 +01:00
2023-04-03 17:07:24 +02:00
2023-04-13 16:39:48 +02:00
2023-02-01 10:25:01 +01:00
2023-04-13 16:40:11 +02:00
2023-04-13 16:39:48 +02:00
2023-03-16 14:12:37 +01:00
2023-03-20 16:51:28 +01:00
2023-04-13 05:07:36 +02:00
2023-03-23 09:06:52 +01:00
2023-03-14 12:23:45 +01:00
2023-04-05 15:11:06 +02:00
2023-04-13 12:29:51 +02:00
2023-01-24 10:20:30 +01:00
2023-04-13 16:39:48 +02:00
2023-03-24 12:50:13 +01:00
2023-04-03 17:07:24 +02:00
2023-03-24 07:45:15 +01:00
2023-04-14 15:05:56 +02:00
2023-04-13 16:39:48 +02:00
2023-03-20 16:51:30 +01:00
2023-03-20 16:51:30 +01:00
2023-04-13 16:39:48 +02:00
2023-03-01 23:28:07 +01:00
2023-04-03 17:07:24 +02:00
2023-04-14 15:05:56 +02:00
2023-04-17 11:47:15 +02:00
2023-04-17 11:46:56 +02:00
2023-04-13 16:40:11 +02:00
2023-04-13 15:25:46 +02:00
2023-03-20 16:51:30 +01:00
2023-04-17 14:14:22 +02:00
2023-02-15 10:14:53 +01:00
2023-03-22 00:53:57 +01:00
2023-03-20 16:51:30 +01:00
2023-04-13 16:40:19 +02:00
2023-02-01 10:25:01 +01:00
2023-04-13 15:25:46 +02:00
2023-04-13 16:39:48 +02:00
2023-04-14 09:39:50 +02:00
2023-04-13 16:39:48 +02:00
2023-01-24 10:20:30 +01:00
2023-04-14 08:33:49 +02:00
2023-04-03 17:07:07 +02:00
2023-04-14 11:49:15 +02:00
2023-04-13 15:25:46 +02:00
2023-03-31 08:50:55 +02:00
2023-02-16 09:01:07 +01:00
2023-04-14 10:45:09 +02:00
2023-03-20 16:51:30 +01:00
2023-03-27 12:47:20 +02:00
2023-04-13 16:40:38 +02:00
2023-04-14 12:54:05 +02:00
2023-04-13 16:39:48 +02:00
2023-04-11 19:48:40 +02:00
2023-04-12 16:33:11 +02:00
2023-04-13 16:40:11 +02:00
2023-02-17 19:30:40 +01:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-03-10 11:23:51 +01:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-06 10:40:49 +02:00
2023-04-06 10:40:49 +02:00
2023-03-30 15:09:36 +02:00
2023-01-18 13:25:32 +01:00
2023-03-17 23:24:11 +01:00
2023-01-27 14:03:35 +01:00
2023-01-18 13:25:32 +01:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 22:47:49 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-03-14 13:30:05 +01:00
2023-04-12 16:33:11 +02:00
2023-03-07 10:06:13 +01:00
2023-04-12 16:33:11 +02:00
2023-03-30 16:23:10 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-02-17 19:30:40 +01:00
2023-04-14 11:49:33 +02:00
2023-04-13 09:31:31 +02:00
2023-01-24 16:18:18 +01:00
2023-02-01 14:37:50 +01:00
2023-02-17 19:30:40 +01:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-03-07 10:06:13 +01:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-11 18:49:32 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-13 16:39:48 +02:00
2023-04-13 16:39:48 +02:00
2023-01-23 16:01:27 +01:00
2023-01-02 09:53:57 +01:00
2023-01-02 09:53:57 +01:00
2023-01-02 09:53:57 +01:00
2023-01-02 09:53:57 +01:00
2023-02-06 09:20:56 +01:00
2023-04-12 16:33:11 +02:00
2023-04-13 16:39:48 +02:00
2023-03-15 16:08:08 +01:00
2023-03-25 02:47:01 +01:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-03-28 16:44:20 +02:00
2023-04-12 16:33:11 +02:00
2023-03-24 12:50:13 +01:00
2023-04-12 08:05:44 +02:00
2023-03-31 15:52:18 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-02-01 14:37:50 +01:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-03-07 10:06:13 +01:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-04-12 16:33:11 +02:00
2023-03-20 16:51:30 +01:00
2023-04-17 11:46:59 +02:00
2023-03-27 20:06:54 +02:00
2023-04-14 15:05:56 +02:00
2023-04-17 15:18:54 +02:00
2023-04-13 16:39:48 +02:00
2023-04-04 20:08:36 +02:00
2023-03-20 07:58:46 +01:00
2023-04-13 16:39:48 +02:00
2023-04-17 08:24:47 +02:00
2023-03-14 15:52:10 +01:00
2023-03-20 16:51:30 +01:00
2023-03-20 16:51:30 +01:00
2023-03-14 15:52:10 +01:00
2022-12-22 15:55:07 +01:00
2023-04-13 16:39:48 +02:00
2023-03-24 12:50:13 +01:00
2023-03-20 16:51:30 +01:00
2023-03-14 15:52:10 +01:00
2023-03-14 15:52:10 +01:00
2023-02-04 10:45:02 +01:00
2023-04-13 17:57:42 +02:00
2023-04-05 09:42:37 +02:00
2023-03-14 15:52:10 +01:00
2023-03-01 17:01:17 +01:00
2023-04-11 11:33:40 +02:00
2023-03-03 17:05:07 +01:00
2023-03-09 10:51:43 +01:00
2023-03-09 10:51:43 +01:00
2023-03-20 16:51:30 +01:00
2023-04-05 19:02:42 +02:00
2023-04-11 18:49:27 +02:00
2023-04-17 14:14:24 +02:00
2023-04-03 17:07:24 +02:00
2023-02-01 10:25:01 +01:00
2023-02-01 10:25:01 +01:00
2023-02-01 10:25:01 +01:00
2023-04-03 17:07:24 +02:00
2023-03-20 16:51:30 +01:00
2023-04-03 17:07:24 +02:00
2023-04-03 17:07:24 +02:00
2023-02-01 10:25:01 +01:00
2023-02-01 10:25:01 +01:00
2023-02-01 10:25:01 +01:00
2023-03-16 20:37:59 +01:00
2023-03-20 16:51:30 +01:00
2023-03-07 16:56:40 +01:00
2023-03-20 16:51:30 +01:00
2023-03-09 10:51:29 +01:00
2023-02-01 10:25:01 +01:00
2023-04-17 14:14:24 +02:00
2023-03-05 15:12:54 +01:00
2023-04-17 09:28:01 +02:00
2023-04-13 16:40:11 +02:00
2023-04-13 16:40:11 +02:00
2023-04-13 16:40:11 +02:00
2023-04-13 16:40:11 +02:00
2023-04-13 16:40:11 +02:00
2023-01-23 16:01:27 +01:00
2023-04-12 15:42:27 +02:00
2023-02-07 16:38:34 +01:00
2023-04-13 16:40:11 +02:00
2023-04-06 16:12:24 +02:00
2023-04-17 09:27:53 +02:00
2023-01-25 16:37:10 +01:00
2023-01-23 16:01:27 +01:00
2023-04-13 16:40:11 +02:00
2023-01-23 16:01:27 +01:00
2023-01-19 18:49:53 +01:00
2023-04-04 13:35:06 +02:00
2023-04-13 04:08:08 +02:00
2023-04-12 15:42:27 +02:00
2023-04-13 16:40:11 +02:00
2023-03-14 15:52:10 +01:00
2023-04-04 11:01:59 +02:00
2023-03-20 16:51:30 +01:00
2023-04-14 10:44:53 +02:00
2023-02-01 10:25:01 +01:00
2023-03-20 16:51:30 +01:00
2023-01-24 10:20:30 +01:00
2023-04-17 14:14:13 +02:00
2023-04-11 09:21:00 +02:00
2023-04-06 17:20:44 +02:00
2023-03-16 14:12:37 +01:00
2023-04-06 17:20:44 +02:00
2023-04-06 17:20:44 +02:00
2023-03-05 15:12:54 +01:00
2023-04-13 05:07:55 +02:00
2023-04-12 22:47:57 +02:00
2023-04-17 09:28:06 +02:00
2023-04-13 15:26:41 +02:00
2023-02-13 15:15:34 +01:00
2023-04-03 17:07:24 +02:00
2023-04-05 17:31:55 +02:00
2023-01-13 16:27:26 +01:00
2023-01-13 16:27:26 +01:00
2023-04-13 19:27:49 +02:00
2023-04-11 09:20:55 +02:00
2023-03-24 12:50:13 +01:00
2023-04-17 11:47:01 +02:00
2023-04-17 13:09:37 +02:00
2023-03-30 10:53:48 +02:00
2023-03-17 15:02:46 +01:00
2023-02-24 10:06:06 +01:00
2023-03-30 18:59:11 +02:00
2023-04-05 15:11:06 +02:00
2023-03-29 23:37:03 +02:00
2023-03-20 16:51:30 +01:00
2023-04-05 12:50:43 +02:00
2023-04-03 17:07:24 +02:00
2023-04-13 16:40:00 +02:00
2023-02-22 20:26:07 +01:00
2023-01-13 16:27:26 +01:00
2023-02-03 11:45:19 +01:00
2023-01-16 15:43:00 +01:00
2023-04-13 16:40:19 +02:00
2023-02-13 15:15:08 +01:00
2023-04-17 13:09:37 +02:00
2023-02-03 05:09:05 +01:00
2023-03-20 16:51:30 +01:00
2023-03-24 01:24:48 +01:00
2023-04-13 16:40:19 +02:00
2023-03-30 07:54:04 +02:00
2023-04-17 14:14:10 +02:00
2023-04-17 09:27:58 +02:00
2023-04-17 09:27:58 +02:00
2023-04-07 17:46:42 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-03-30 15:09:33 +02:00
2023-04-17 14:14:16 +02:00
2023-03-31 22:13:48 +02:00
2023-04-13 16:39:48 +02:00
2023-03-08 17:33:37 +01:00
2023-03-30 17:57:58 +02:00
2023-04-13 16:39:48 +02:00
2023-02-01 10:25:01 +01:00
2023-04-14 10:44:58 +02:00
2023-03-24 12:50:13 +01:00
2023-04-14 17:38:04 +02:00
2023-04-13 04:08:11 +02:00
2023-04-14 17:38:04 +02:00
2023-04-17 15:18:54 +02:00
2023-04-13 16:39:48 +02:00
2023-04-04 20:08:37 +02:00
2023-04-13 17:57:56 +02:00
2023-02-03 10:25:00 +01:00
2023-04-11 15:17:20 +02:00
2023-04-04 16:02:12 +02:00
2023-04-03 17:07:24 +02:00
2023-04-03 17:07:24 +02:00
2023-04-17 09:28:03 +02:00
2023-03-08 17:33:37 +01:00
2023-03-29 09:33:35 +02:00
2023-04-17 14:14:27 +02:00
2023-04-17 10:34:32 +02:00
2023-04-12 18:58:29 +02:00
2023-04-14 11:49:25 +02:00
2023-04-17 08:24:47 +02:00
2023-04-17 11:47:15 +02:00
2023-04-03 17:07:24 +02:00
2023-01-17 20:58:34 +01:00
2023-04-13 16:40:11 +02:00
2023-03-20 16:51:30 +01:00
2023-04-17 08:24:47 +02:00
2023-04-03 17:07:24 +02:00
2023-04-03 17:07:24 +02:00
2023-04-03 17:07:24 +02:00
2023-04-03 17:07:24 +02:00
2023-04-05 12:50:43 +02:00
2023-04-03 17:07:24 +02:00
2023-01-16 19:45:57 +01:00
2023-04-03 17:07:24 +02:00
2023-04-03 17:07:24 +02:00
2023-04-13 16:40:11 +02:00
2023-04-05 12:50:43 +02:00
2023-04-05 12:50:43 +02:00
2023-04-05 12:50:43 +02:00
2023-04-06 17:20:44 +02:00
2023-04-13 16:40:11 +02:00
2023-04-03 17:07:24 +02:00
2023-04-03 17:07:24 +02:00
2023-04-13 16:40:11 +02:00
2023-04-03 17:07:24 +02:00
2023-04-03 17:07:24 +02:00
2023-04-17 08:24:47 +02:00
2023-04-17 08:24:47 +02:00
2023-03-20 16:51:30 +01:00
2023-03-20 16:51:30 +01:00
2023-04-17 08:24:47 +02:00
2023-02-24 18:16:11 +01:00
2023-04-12 14:02:35 +02:00
2023-04-17 08:24:47 +02:00
2023-03-15 13:19:45 +01:00
2023-04-03 17:07:24 +02:00
2023-04-05 12:50:43 +02:00
2023-03-24 19:21:32 +01:00
2023-03-24 11:08:32 +01:00
2023-04-05 12:50:43 +02:00
2023-03-27 20:06:54 +02:00
2023-04-13 16:40:11 +02:00
2023-04-05 12:50:43 +02:00
2023-04-04 13:35:12 +02:00
2023-01-27 23:17:35 +01:00
2023-04-17 11:47:15 +02:00
2023-04-14 15:05:56 +02:00
2023-03-22 17:03:28 +01:00
2023-04-13 04:08:35 +02:00
2023-04-17 08:24:47 +02:00