fsf changes, meant to be rebased on upstream
[squirrelmail.git] / plugins / message_details / message_details_bottom.php
index 8877b999124d0e5d1b5a3f6b09920814bcf7609c..56391e054a8f07188deadc63c7e42d5832a31819 100644 (file)
@@ -7,7 +7,7 @@
  *
  * @author Marc Groot Koerkamp
  * @copyright 2002 Marc Groot Koerkamp, The Netherlands
- * @copyright 2002-2010 The SquirrelMail Project Team
+ * @copyright 2002-2022 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
@@ -112,11 +112,12 @@ function CalcEntity($entString, $direction) {
  * @access public
  */
 function get_message_details($mailbox, $passed_id, $passed_ent_id=0, $stripHTML=FALSE) {
-    global $imapServerAddress, $imapPort, $color,$msgd_8bit_in_hex, $username;
+    global $imapServerAddress, $imapPort, $imap_stream_options,
+           $color,$msgd_8bit_in_hex, $username;
 
     $returnValue = '';
 
-    $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
+    $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
     $read = sqimap_mailbox_select($imapConnection, $mailbox);
     if (!empty($passed_ent_id))
         $body = sqimap_run_command($imapConnection, "FETCH $passed_id BODY[$passed_ent_id]",true, $response, $readmessage, TRUE);
@@ -130,7 +131,7 @@ function get_message_details($mailbox, $passed_id, $passed_ent_id=0, $stripHTML=
     $messageheaderstart=false;
     $boundaries = array();
     $entities = array();
-    session_unregister("entities");
+    sqsession_unregister("entities");
     $pre = '<b>';
     $end = '</b>';
     $entStr = '';
@@ -210,7 +211,7 @@ function get_message_details($mailbox, $passed_id, $passed_ent_id=0, $stripHTML=
             }
         }
 
-        if (($line != '' && $line{0} == '-' || $header)  && isset($boundaries[0])) {
+        if (($line != '' && $line[0] == '-' || $header)  && isset($boundaries[0])) {
             $cnt=count($boundaries)-1;
             $bnd = $boundaries[$cnt]['bnd'];
             $bndreg = $boundaries[$cnt]['bndreg'];
@@ -220,7 +221,7 @@ function get_message_details($mailbox, $passed_id, $passed_ent_id=0, $stripHTML=
                 $bndlen = strlen($reg[1]);
                 $bndend = false;
                 if (strlen($line) > ($bndlen + 3)) {
-                    if ($line{$bndlen+2} == '-' && $line{$bndlen+3} == '-')
+                    if ($line[$bndlen+2] == '-' && $line[$bndlen+3] == '-')
                         $bndend = true;
                 }
                 if ($bndend) {
@@ -238,9 +239,9 @@ function get_message_details($mailbox, $passed_id, $passed_ent_id=0, $stripHTML=
                     $entStr = CalcEntity("$entStr",0);
                     $content_indx++;
                     $content[$content_indx]=array();
-                    $content[$content_indx]['ent'] = '<a href="#'."$entStr \">$entStr".'</a>';
+                    $content[$content_indx]['ent'] = '<a href="#' . $entStr . '">' . $entStr . '</a>';
                     $pre .= '</div><div class="entheader" id="'.
-                        $entStr.'H"><a name="'."$entStr".'"><b><font color="'.$color[2].'">';
+                        $entStr.'H"><a name="'."$entStr".'"></a><b><font color="'.$color[2].'">';
                     $end .= '</font></b>';
                     $header = true;
                     $mimepart = false;
@@ -260,7 +261,7 @@ function get_message_details($mailbox, $passed_id, $passed_ent_id=0, $stripHTML=
                             $entities["$entStr"]['contenttype']=$reg[2].'/'.$reg[3];
                         }
                     } else if (!$nameset && preg_match("/^.*(name=\s*)\"(.*)\".*/i",$line,$reg)) {
-                        $name = htmlspecialchars($reg[2]);
+                        $name = sm_encode_html_special_chars($reg[2]);
                         $content[$content_indx]['name'] = decodeHeader($name);
                         $nameset = true;
                         if (isset($entities["$entStr"])) {
@@ -285,7 +286,7 @@ function get_message_details($mailbox, $passed_id, $passed_ent_id=0, $stripHTML=
         if ($stripHTML) {
             $message_body .= $line . "\r\n";
         } else {
-            $line = htmlspecialchars($line);
+            $line = sm_encode_html_special_chars($line);
             if ($msgd_8bit_in_hex) $line = msgd_convert_to_hex($line);
             $message_body .= "$pre"."$line"."$end"."\r\n";
         }