-
Notifications
You must be signed in to change notification settings - Fork 161
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
When reading literal_data from mail body from IMAP, use byte count instead of string-length count. #1217
Conversation
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.
Looks good! Fix the pipelines, and we’ll merge. We'll keep an eye on the changes. Thanks!
@kambereBr : I can't really figure out how to get the Selenium test to pass. Can't see that my code should have change what the test is checking. Is the test somehow broken? Or has a previous commit inadvertently broken it? |
I installed the version in my feature-branch, with bunch of emails and 3 accounts. With the exception of an already reported issue, everything works as expected. In particular, the Selenium test that is failing is not reproducible in the browser. |
Ok, I did some searching around. Seems the test was failing due to a race condition.
Someone might want to re-review this PR, as I fiddled with the tests. |
Well, I think it reverts some of the recent changes so it restores code to what is was for a long time. Here are recent modification on this file: |
Here is the change: #1051 Could some of the other changes have unintendended negative consequences? |
Probably yes, but it's hard to say for sure. We'll only know when we encounter issues in specific use cases. |
Ok, we'll stay alert :-) #1224 |
@indridieinarsson thanks for the PR but since we have more problems than the mentioned issue with literal string lengths, I combined your code with other fixes and some unit tests to catch this issue in the future here: #1230 |
Pullrequest
This is a first attempt to fix issue #1119.
I'm not very proficient in php, and not knowledgeable about imap, so for the love of all that is good and holy, review and test this properly.
Take a look at this chunk from hm-imap-base.php:
If I understand this writing correctly: https://www.rfc-editor.org/rfc/rfc3501#section-4.3, the number in curly braces that is being read into $literal_size, is the number of bytes in the email body, which is then sent over the wire right away.
Therefore, all string-size calculations in
read_literal()
should use thestrsize
rather thanmb_strsize
command. My theory is that the issue #1119 is caused by this: the number of bytes read are underestimated sincemb_strsize
is smaller thanstrsize
for real multibyte strings. We then end up trying to read strings from the server after the server has sent the entire message, causing the code to hang.Issues
Checklist
This touches the code that reads the email body, pretty central for an email client. This PR will change behaviour in cases when the body of the message contains multibyte characters (ÞþæÆöÖðÐáÁóÓ etc.).