Changeset 4cebb76 in github


Ignore:
Timestamp:
May 13, 2012 11:17:11 AM (12 months ago)
Author:
Aleksander Machniak <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo
Children:
198d194
Parents:
1c9e571 (diff), 14f22f3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge pull request #4 from rasky/fix_uuencode

Fix support for large uuencode attachments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_message.php

    rbe98dfc2 r14f22f3  
    656656        $parts = array(); 
    657657        // FIXME: line length is max.65? 
    658         $uu_regexp = '/begin [0-7]{3,4} ([^\n]+)\n(([\x21-\x7E]{0,65}\n)+)`\nend/s'; 
     658        $uu_regexp = '/begin [0-7]{3,4} ([^\n]+)\n/s'; 
    659659 
    660660        if (preg_match_all($uu_regexp, $part->body, $matches, PREG_SET_ORDER)) { 
    661             // remove attachments bodies from the message body 
    662             $part->body = preg_replace($uu_regexp, '', $part->body); 
    663661            // update message content-type 
    664662            $part->ctype_primary   = 'multipart'; 
    665663            $part->ctype_secondary = 'mixed'; 
    666664            $part->mimetype        = $part->ctype_primary . '/' . $part->ctype_secondary; 
     665            $uu_endstring = "`\nend\n"; 
    667666 
    668667            // add attachments to the structure 
    669668            foreach ($matches as $pid => $att) { 
     669                $startpos = strpos($part->body, $att[1]) + strlen($att[1]) + 1; // "\n" 
     670                $endpos = strpos($part->body, $uu_endstring); 
     671                $filebody = substr($part->body, $startpos, $endpos-$startpos); 
     672 
     673                // remove attachments bodies from the message body 
     674                $part->body = substr_replace($part->body, "", $startpos, $endpos+strlen($uu_endstring)-$startpos); 
     675 
    670676                $uupart = new rcube_message_part; 
    671677 
    672678                $uupart->filename = trim($att[1]); 
    673679                $uupart->encoding = 'stream'; 
    674                 $uupart->body     = convert_uudecode($att[2]); 
     680                $uupart->body     = convert_uudecode($filebody); 
    675681                $uupart->size     = strlen($uupart->body); 
    676682                $uupart->mime_id  = 'uu.' . $part->mime_id . '.' . $pid; 
     
    683689                unset($matches[$pid]); 
    684690            } 
     691 
     692            // remove attachments bodies from the message body 
     693            $part->body = preg_replace($uu_regexp, '', $part->body); 
    685694        } 
    686695 
Note: See TracChangeset for help on using the changeset viewer.