-
Notifications
You must be signed in to change notification settings - Fork 262
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
Change how charsets are detected for emails #5882
Conversation
this looks good for me too |
This comment has been minimized.
This comment has been minimized.
4bda549
to
fac906a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throws an error Could not detect charset for message
on a harmless message that worked fined before.
Test email as sent from Thunderbird. It contains an image from Unsplash. I could reproduce it using other images too so this seems to be an issue with attached images.
Error from the console
{
"app": "mail",
"uid": "admin",
"error": {
"isError": true,
"debug": true,
"type": "OCA\\Mail\\Exception\\ServiceException",
"code": 0,
"message": "Could not detect charset for message",
"trace": [
{
"file": "/srv/http/dev_apps/mail/lib/Model/IMAPMessage.php",
"line": 566,
"function": "loadBodyData",
"class": "OCA\\Mail\\Model\\IMAPMessage"
},
{
"file": "/srv/http/dev_apps/mail/lib/Model/IMAPMessage.php",
"line": 437,
"function": "handleTextMessage",
"class": "OCA\\Mail\\Model\\IMAPMessage"
},
{
"file": "/srv/http/dev_apps/mail/lib/Model/IMAPMessage.php",
"line": 377,
"function": "getPart",
"class": "OCA\\Mail\\Model\\IMAPMessage"
},
{
"file": "/srv/http/dev_apps/mail/lib/Model/IMAPMessage.php",
"line": 102,
"function": "loadMessageBodies",
"class": "OCA\\Mail\\Model\\IMAPMessage"
},
{
"file": "/srv/http/dev_apps/mail/lib/IMAP/MessageMapper.php",
"line": 242,
"function": "__construct",
"class": "OCA\\Mail\\Model\\IMAPMessage"
},
{
"function": "OCA\\Mail\\IMAP\\{closure}",
"class": "OCA\\Mail\\IMAP\\MessageMapper"
},
{
"file": "/srv/http/dev_apps/mail/lib/IMAP/MessageMapper.php",
"line": 256,
"function": "array_map"
},
{
"file": "/srv/http/dev_apps/mail/lib/IMAP/MessageMapper.php",
"line": 69,
"function": "findByIds",
"class": "OCA\\Mail\\IMAP\\MessageMapper"
},
{
"file": "/srv/http/dev_apps/mail/lib/Service/MailManager.php",
"line": 180,
"function": "find",
"class": "OCA\\Mail\\IMAP\\MessageMapper"
},
{
"file": "/srv/http/dev_apps/mail/lib/Controller/MessagesController.php",
"line": 249,
"function": "getImapMessage",
"class": "OCA\\Mail\\Service\\MailManager"
},
{
"file": "/srv/http/lib/private/AppFramework/Http/Dispatcher.php",
"line": 217,
"function": "getBody",
"class": "OCA\\Mail\\Controller\\MessagesController"
},
{
"file": "/srv/http/lib/private/AppFramework/Http/Dispatcher.php",
"line": 126,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher"
},
{
"file": "/srv/http/lib/private/AppFramework/App.php",
"line": 157,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher"
},
{
"file": "/srv/http/lib/private/Route/Router.php",
"line": 302,
"function": "main",
"class": "OC\\AppFramework\\App"
},
{
"file": "/srv/http/lib/base.php",
"line": 1006,
"function": "match",
"class": "OC\\Route\\Router"
},
{
"file": "/srv/http/index.php",
"line": 36,
"function": "handleRequest",
"class": "OC"
}
]
}
}
This comment has been minimized.
This comment has been minimized.
Ah interesting. Attached, not embedded as base64? |
I added the image as a regular attachment. At least in Thunderbird it is detected as an attachment and is not shown inline. Here is the relevant excerpt from the
|
#1037 is also related |
Figured it out. PHP implicit bools were fooling me. As the content is |
Would it be possible to use symfony/unicode or hoa/ustring to avoid encoding problems? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit scary. Let's add tests to cover the edge cases.
👍 otherwise
Not quite sure how to test this as the complete function chain is private. |
368320d
to
b557369
Compare
Move the charset logic into a new class, add unit tests for it and use it in the other complex class. |
|
||
// Still UTF8, no need to convert | ||
if($charset !== null && strtoupper($charset) === 'UTF-8') { | ||
return $data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none of the tests is able to reach a line below this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still the case. either the charset parameter is set and used, or mb detects the string as UTF-8
$iso2022jpMimePart_noCharset = new Horde_Mime_Part(); | ||
$iso2022jpMimePart_noCharset->setContents('外せ園査リツハワ題'); | ||
// Korean - not in mb nor iconv | ||
// $iso106461MimePart = new Horde_Mime_Part(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ISO 10646-1 is impossible to get working for me. The coding is not mentioned in any report. Can we skip this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 we can get this in
Signed-off-by: Anna Larch <anna@nextcloud.com>
0cbdb53
to
176e074
Compare
Fixes #5845
Fixes #5834