Skip to content

bug in Roundcube's ImapClient's fetch method #32

Closed
@IZSkiSurfer

Description

@IZSkiSurfer

I came across a bug in the fetch method of Roundcube\ImapClient class or it's usage in the Message class.
In Message class' fetchBody method e.g. you do the following:
` $messages = $client->fetch($imap->getMailboxName(), $messageNum, $isUid, ['BODY[TEXT]']);

    return $messages[$messageNum]->bodypart['TEXT'];`

Let's say $messageNum is 12345 and $isUid is true.
You await an element in the $messages array with the key 12345.

In ImapClient this happens:
A???? UID FETCH 12345 ... is sent and you'll (at least I do) get back * ???? FETCH (UID 12345 ...
Afaik ???? is the same so you'll know to what request that fetch response belongs.
You then grab that ???? and use it as the key in your return array.
But outside of the function you await that the key is equal to the $messageNum you passed to the method.

So I would suggest adding near the end of Roundcube\ImapClient's fetch method something like:
if ($is_uid && !empty($result[$id]->uid)) { $result[$result[$id]->uid] = $result[$id]; } or better collect all data in a temporary variable first and do the $result assignment with the correct key at the end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions