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

Obvious bug in LegacyProtocol::headers method #125

Closed
zssarkany opened this issue Apr 6, 2021 · 2 comments
Closed

Obvious bug in LegacyProtocol::headers method #125

zssarkany opened this issue Apr 6, 2021 · 2 comments
Labels
bug Something isn't working validated

Comments

@zssarkany
Copy link

zssarkany commented Apr 6, 2021

Describe the bug

Uid function argument (sequence type) of header method gets overwritten by foreach. This results, that UID-based sequence is used for messageId-based header enumeration as well.

Problematic block:

    public function headers($uids, $rfc = "RFC822", $uid = false){
        $result = [];
        $uids = is_array($uids) ? $uids : [$uids];
        foreach ($uids as $uid) {
            $result[$uid] = \imap_fetchheader($this->stream, $uid, $uid ? IMAP::FT_UID : IMAP::NIL);
        }
        return $result;
    }

Possible solution changing variable name from uid to id in foreach:

    public function headers($uids, $rfc = "RFC822", $uid = false){
        $result = [];
        $uids = is_array($uids) ? $uids : [$uids];
        foreach ($uids as $id) {
            $result[$id] = \imap_fetchheader($this->stream, $id, $uid ? IMAP::FT_UID : IMAP::NIL);
        }
        return $result;
    }

Used config

irrelevant

Code to Reproduce

irrelevant

Expected behavior

Foreach should not overwrite $uid function argument.

Screenshots

n/a

Desktop / Server (please complete the following information):

irrelevant

Additional context

n/a

@zssarkany zssarkany changed the title Obvius bug in LegacyProtocol::headers method Obvious bug in LegacyProtocol::headers method Apr 6, 2021
@zssarkany
Copy link
Author

The same issue exists for content and flags methods.

@Webklex
Copy link
Owner

Webklex commented Jun 17, 2021

Hi @zssarkany ,
many thanks for your report! :)

Best regards,

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