Skip to content
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

Fetch body is overwritten in ImapProtocol, with fix solution #290

Closed
thin-k-design opened this issue Sep 30, 2022 · 1 comment
Closed

Fetch body is overwritten in ImapProtocol, with fix solution #290

thin-k-design opened this issue Sep 30, 2022 · 1 comment
Labels
bug Something isn't working validated

Comments

@thin-k-design
Copy link
Contributor

thin-k-design commented Sep 30, 2022

Describe the bug
Data is beeing overwritten when reading the response in ImapProtocol. This happens, when the imap server sends back two responses for one request command. Here is an example:

>> TAG14 UID FETCH 182835 (RFC822.TEXT)
<< * 2005 FETCH (UID 182835 RFC822.TEXT {645163}
<< --000000000000ae3e6805e9e1bece
<< Content-Type: multipart/alternative; boundary="000000000000ae3e6605e9e1becc"
<<
<< --000000000000ae3e6605e9e1becc
<< Content-Type: text/plain; charset="UTF-8"
<<
<< Testbody
<<
<< --000000000000ae3e6605e9e1becc
{{... rest of the message content ...}}
<< --000000000000ae3e6805e9e1bece-- FLAGS (\Seen))
<< * 2005 FETCH (UID 182835 FLAGS (\Seen))
<< TAG14 OK Success

First the content after * 2005 FETCH (UID 182835 RFC822.TEXT {645163} is beeing correctly parsed.
But the line * 2005 FETCH (UID 182835 FLAGS (\Seen)) is beeing parsed after the body and $data is beeing overwritten in:
Connection\Protocols\ImapProtocol::fetch() Line 616

            $data = "";

            // if we only want one item we return that one directly
            if (count($items) == 1) {
                if ($tokens[2][0] == $items[0]) {
                    $data = $tokens[2][1];
                } elseif ($uid && $tokens[2][2] == $items[0]) {
                    $data = $tokens[2][3];
                } else {
                ...

Should be changed in

            if (!isset($data)) {
                $data = "";
            }

            // if we only want one item we return that one directly
            if (count($items) == 1) {
                if ($tokens[2][0] == $items[0]) {
                    $data = $tokens[2][1];
                } elseif ($uid && $tokens[2][2] == $items[0]) {
                    $data = $tokens[2][3];
                } else {
                ...
@Webklex Webklex added bug Something isn't working validated labels Sep 30, 2022
@thin-k-design
Copy link
Contributor Author

Has been fixed in #233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working validated
Projects
None yet
Development

No branches or pull requests

2 participants