Changeset 4617


Ignore:
Timestamp:
06/16/11 15:12:20 (13 years ago)
Author:
emersonfaria
Message:

Ticket #2015 - Implementacoes para codificar o corpo como BASE64 nas mensagens encaminhadas pelo Galaxy S

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/z-push/backend/imap.php

    r4613 r4617  
    205205        // if this is a multipart message with a boundary, we must use the original body 
    206206        if ($use_orgbody) { 
    207             list(,$body) = $mobj->_splitBodyHeader($rfc822); 
    208             $repl_body = $this->getBody($message); 
     207            list(,$body) = $mobj->_splitBodyHeader($rfc822);  
     208            $repl_body = $this->getBody($message);  
     209            if ($message->parts[0]->headers["content-transfer-encoding"] == "base64") $multipart_text_cte_base64 = true; 
     210            else $multipart_text_cte_base64 = false; 
    209211        } 
    210212        else 
     
    216218            // receive entire mail (header + body) to decode body correctly 
    217219            $origmail = @imap_fetchheader($this->_mbox, $reply, FT_UID) . @imap_body($this->_mbox, $reply, FT_PEEK | FT_UID); 
     220 
    218221            $mobj2 = new Mail_mimeDecode($origmail); 
    219222            // receive only body 
     
    284287                    //$body is quoted-printable encoded while $repl_body and $nbody are plain text, 
    285288                    //so we need to decode $body in order replace to take place 
    286                     $body = str_replace($repl_body, $nbody, quoted_printable_decode($body)); 
     289                    if (!$multipart_text_cte_base64) { 
     290                       $body = str_replace($repl_body, $nbody, quoted_printable_decode($body)); 
     291                    } else { 
     292                       $body = str_replace(base64_encode($repl_body), base64_encode($nbody), $body);                    } 
    287293                } 
    288294                else 
     
    771777                        $output = new SyncMail(); 
    772778 
    773                         $body = $this->getBody($message); 
     779                        $body = $this->getBody($message, true); // true - Truncate body due to celular memory limit 
    774780                        // truncate body, if requested 
    775781                        if(strlen($body) > $truncsize) { 
     
    968974        /* Parse the message and return only the plaintext body 
    969975         */ 
    970         function getBody($message) { 
     976        function getBody($message, $trunc = false) { 
    971977                $body = ""; 
    972978                $htmlbody = ""; 
     
    976982                if(!isset($body) or $body === '') { 
    977983                        $this->getBodyRecursive($message, "html", $body); 
     984 
    978985                        // remove css-style tags 
    979986                        $body = preg_replace("/<style.*?<\/style>/is", "a", $body); 
     
    10261033                        // End change block - Remove the HTML tags using the 'html2text' Linux application 
    10271034                } 
     1035 
    10281036                return $body; 
    10291037        } 
     
    10371045 
    10381046                if(strcasecmp($message->ctype_primary,"multipart")==0 && isset($message->parts) && is_array($message->parts)) { 
    1039                         foreach($message->parts as $part) { 
     1047                foreach($message->parts as $part) { 
    10401048                                if(!isset($part->disposition) || strcasecmp($part->disposition,"attachment"))  { 
    10411049                                        $this->getBodyRecursive($part, $subtype, $body); 
Note: See TracChangeset for help on using the changeset viewer.