Skip to content

Obvious bug in LegacyProtocol::headers method #125

@zssarkany

Description

@zssarkany

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions