Changeset 4781


Ignore:
Timestamp:
07/18/11 11:30:24 (13 years ago)
Author:
airton
Message:

Ticket #2138 - Caracter ndesejado na visualizacao de mensagem vinda do MS Outlook

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.imap_functions.inc.php

    r4777 r4781  
    671671                                      $content .= $this->builderMsgHeader($part); 
    672672 
    673                                    $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body,$part->ctype_parameters['charset'])).'</pre>'; 
     673                                   $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body,$part->ctype_parameters['charset'],false)).'</pre>'; 
    674674                                } 
    675675 
     
    696696                            { 
    697697                                $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 
    698                                 $content .= '<pre>'. $this->decodeMailPart($part->body, $structure->ctype_parameters['charset']).'</pre>'; 
     698                                $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body, $structure->ctype_parameters['charset'],false)).'</pre>'; 
    699699                                $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 
    700700                            } 
     
    731731                                      $content .= $this->builderMsgHeader($part); 
    732732 
    733                                    $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body,$part->ctype_parameters['charset'])).'</pre>'; 
     733                                   $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body,$part->ctype_parameters['charset'],false)).'</pre>'; 
    734734                                } 
    735735 
     
    750750                            { 
    751751                                $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 
    752                                 $content .= '<pre>'.  htmlentities($this->decodeMailPart($part->body, $structure->ctype_parameters['charset'])).'</pre>'; 
     752                                $content .= '<pre>'.  htmlentities($this->decodeMailPart($part->body, $structure->ctype_parameters['charset'],false)).'</pre>'; 
    753753                                $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 
    754754                            } 
     
    10931093        } 
    10941094 
     1095        /*  
     1096         * Converte textos utf8 para o padrão html.  
     1097         * @link http://php.net/manual/en/function.utf8-decode.php  
     1098         * @author luka8088 <luka8088@gmail.com>  
     1099         */  
     1100        function utf8_to_html ($data)  
     1101        {  
     1102            return preg_replace("/([\\xC0-\\xF7]{1,1}[\\x80-\\xBF]+)/e", '$this->_utf8_to_html("\\1")', $data);  
     1103        }  
     1104                  
     1105        function _utf8_to_html ($data)  
     1106        {  
     1107            $ret = 0;  
     1108                foreach((str_split(strrev(chr((ord($data{0}) % 252 % 248 % 240 % 224 % 192) + 128) . substr($data, 1)))) as $k => $v)  
     1109                        $ret += (ord($v) % 128) * pow(64, $k);  
     1110                    return "&#$ret;";  
     1111        }  
     1112        //------------------------------------------------------------------------------//  
     1113         
     1114         
     1115         
     1116         
    10951117                /** 
    10961118         * Decodifica uma part da mensagem para iso-8859-1 
     
    10991121         * @return <type> string decodificada 
    11001122         */ 
    1101         function decodeMailPart($part, $encode) 
     1123        function decodeMailPart($part, $encode, $html = true) 
    11021124        { 
    11031125            switch (strtolower($encode)) 
     
    11081130 
    11091131                case 'utf-8': 
    1110                     return utf8_decode($part); 
     1132                    if ($html)  
     1133                                                return  $this->utf8_to_html($part);  
     1134                        else        
     1135                                                return  utf8_decode ($part); 
    11111136                    break; 
    11121137 
     
    11861211                        if(($msg_subtype == "html" || $msg_subtype == 'plain') && ($disposition != 'attachment')) 
    11871212                        { 
    1188                                 $content = $this->decodeMailPart($structure->body, $structure->ctype_parameters['charset']) ; 
     1213                                 
    11891214 
    11901215                                if(strtolower($msg_subtype) == 'plain') 
    11911216                                { 
    1192                                         $content = str_replace(array('<', '>'), array(' #$<$# ', ' #$>$# '), $content); 
     1217                                        $content = $this->decodeMailPart($structure->body, $structure->ctype_parameters['charset'],false); 
     1218                                                                                $content = str_replace(array('<', '>'), array(' #$<$# ', ' #$>$# '), $content); 
    11931219                                        $content = htmlentities($content); 
    11941220                                        $content = $this -> replace_links($content); 
     
    11981224                                        return $return; 
    11991225                                } 
     1226                                                                $content = $this->decodeMailPart($structure->body, $structure->ctype_parameters['charset']); 
    12001227                        } 
    12011228 
     
    12111238                    { 
    12121239                        $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 
    1213                         $content .= '<pre>'.$this->decodeMailPart($structure->body, $structure->ctype_parameters['charset']).'</pre>'; 
     1240                        $content .= '<pre>'.htmlentities($this->decodeMailPart($structure->body, $structure->ctype_parameters['charset'],false)).'</pre>'; 
    12141241                        $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>"; 
    12151242                    } 
Note: See TracChangeset for help on using the changeset viewer.