Made special character handling better in From and Subject
[squirrelmail.git] / functions / mailbox.php
index 83b77febe01a0546424d2da1c4b143c87d59595e..45dbbb7a97bf802488a1e87876a8b3b5a004b119 100644 (file)
       }
    }
 
+   /**  This function sends a request to the IMAP server for headers, 50 at a time
+    **  until $end is reached.  I originally had it do them all at one time, but found
+    **  it slightly faster to do it this way.
+    **
+    **  Originally we had getMessageHeaders get the headers for one message at a time.
+    **  Doing it in bunches gave us a speed increase from 9 seconds (for a box of 800
+    **  messages) to about 3.5 seconds.
+    **/
    function getMessageHeaders($imapConnection, $start, $end, &$from, &$subject, &$date) {
-
       $rel_start = $start;
-
       if (($start > $end) || ($start < 1)) {
          echo "Error in message header fetching.  Start message: $start, End message: $end<BR>";
          exit;
                $from_num++;
             }
             else if (substr($read, 0, 5) == "Date:") {
-               $read = ereg_replace("<", "[", $read);
-               $read = ereg_replace(">", "]", $read);
+               $read = ereg_replace("<", "&lt;", $read);
+               $read = ereg_replace(">", "&gt;", $read);
                $date[$date_num] = substr($read, 5, strlen($read) - 6);
                $date_num++;
             }
             else if (substr($read, 0, 8) == "Subject:") {
-               $read = ereg_replace("<", "[", $read);
-               $read = ereg_replace(">", "]", $read);
+               $read = ereg_replace("<", "&lt;", $read);
+               $read = ereg_replace(">", "&gt;", $read);
                $subject[$subj_num] = substr($read, 8, strlen($read) - 9);
                $subj_num++;
             }
       fputs($imapConnection, "messageStore STORE $i:$q +FLAGS (\\$flag)\n");
    }
 
+   /**  This function gets the flags for message $j.  It does only one message at a
+    **  time, rather than doing groups of messages (like getMessageHeaders does).
+    **  I found it one or two seconds quicker (on a box of 800 messages) to do it
+    **  individually.  I'm not sure why it happens like that, but that's what my
+    **  testing found.  Perhaps later I will be proven wrong and this will change.
+    **/
    function getMessageFlags($imapConnection, $j, &$flags) {
       /**   * 2 FETCH (FLAGS (\Answered \Seen))   */
       fputs($imapConnection, "messageFetch FETCH $j:$j FLAGS\n");