Menu

#2867 1.5.2 svn Parenthesis missing functions/imap_messages.php on line 120

Can't Reproduce
open
nobody
None
5
2023-09-27
2023-09-02
No

After a fresh svn update on the 1.5.2 branch on 8/30/23 the heading and message list area were back and the following error was displayed:

[Thu Aug 31 20:43:42.072929 2023] [fcgid:warn] [pid 12712] 
[client 192.168.6.104:56166] mod_fcgid: stderr: PHP Parse error:  syntax error,
unexpected token "[" in /srv/http/htdocs/squirrelmail/functions/imap_messages.php
on line 120, referer: https://2pi.3111skyline.com/squirrelmail/src/left_main.php

That corresponds to the following line in sqimap_toggle_flag():

/**

 * Set a flag on the provided uid list
 * @param  resource imap connection
 * @param  mixed $id Normally an array which is a list with message UIDs to be flagged
 *                   or a string range such as "1:*" or a simple integer
 * @param  string $flag Flags to set/unset flags can be i.e.'\Seen', '\Answered', '\Seen \Answered'
 * @param  bool   $set  add (true) or remove (false) the provided flag
 * @param  bool   $handle_errors Show error messages in case of a NO, BAD or BYE response
 * @return array  $aMessageList array with messages containing the new flags and UID @see parseFetch
 */
function sqimap_toggle_flag($imap_stream, $id, $flag, $set, $handle_errors) {
    $msgs_id = sqimap_message_list_squisher($id);
    $set_string = ($set ? '+' : '-');

    /*

    * We need to return the data in the same order as the caller supplied
    * in $id, but IMAP servers are free to return responses in
    * whatever order they wish... So we need to re-sort manually
    */
    $aMessageList = array();
    if (is_array($id)) {
        for ($i=0; $i<count($id); $i++) {
            $aMessageList[$id[$i]] = array();
        }
    }

    $aResponse = sqimap_run_command_list($imap_stream, "STORE $msgs_id ".$set_string."FLAGS ($flag)", $handle_error
s, $response, $message, TRUE);

    // parse the fetch response
    $parseFetchResults=parseFetch($aResponse,$aMessageList);

    // some broken IMAP servers do not return UID elements on UID STORE
    // if this is the case, then we need to do a UID FETCH
    if (!empty($parseFetchResults)
     && !isset($parseFetchResults)['UID']) {
120  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        $aResponse = sqimap_run_command_list($imap_stream, "FETCH $msgs_id (FLAGS)", $handle_errors, $response, $me
ssage, TRUE);
        $parseFetchResults = parseFetch($aResponse,$aMessageList);
    }

    return ($parseFetchResults);
}

The problem is the index ['UID'] is applied to !isset($parseFetchResults)['UID'] where it should be applied as !isset(($parseFetchResults)['UID'])) Adding the parens solves that issue.

Server/Install Details:

  Running on Archlinux: 6.4.12-arch1-1
  Apache/2.4.57 (Unix) OpenSSL/3.1.2 mod_fcgid/2.3.9 PHP/8.1.22
  postfix 3.8.1-3
  dovecot 2.3.20-2

Discussion

  • david rankin

    david rankin - 2023-09-02

    The fix should actually be !isset($parseFetchResults['UID']))

     
  • david rankin

    david rankin - 2023-09-27

    Note, I messed the status up when I created this bug and forgot to change from "Cannot Reproduce" to "Produces Error". If one of the admins could update I would appreciate it. (I should be able to do it, but I can' find any widget to edit the original bug???)

     

Log in to post a comment.

MongoDB Logo MongoDB