roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.77k stars 1.62k forks source link

UUEncoded attachment are not read correctly #2163

Closed rcubetrac closed 14 years ago

rcubetrac commented 15 years ago

Reported by jernst on 7 May 2009 14:58 UTC as Trac ticket #1485839

Here is an example mail that doesn't show up correctly in Roundcube.

[Thu, 7 May 2009 16:32:14 +0200 From: X To: Y Subject: Facsimile received from 022123456 Message-Id: 20090507163149-0223642891.22818@voip

Resolution: 204, 98 pixels/inch Page Number: 0-1 Fax Data: clean (0 = 0x0) Fax Receive Time: 5 secs Fax DCS: 00 55 1E

begin 644 20090507163149-0223642891.pdf M)5!$1BTQ+C$@"B7BX3"C$@,"!O8FH/#P@"B](...] Date:)4>7!E("]#871A;&]G(HO M4&%G97,@,RP(%(@"CX^"F5N9&]B:@HR(#@;V)J"CP\(HO0W)E871I;VY$ M871E("A$.C(P,#DP-3W,38S,C$P_0HO36]D1&%T92H1#HR,#Y,#4P-S$V M,S(Q,"D_+U!R;V1U8V5R("AL:6)T:69F("\@=&EF9C)P9&8@+2R,#V,#,R M,RO(&0I"B]#<F5A=&]R("AS<&%N9'-P0H^/B*96YD;V)J"C,@,"!O8FH* M/#P@"B]4>7!E("]086=E<R+TMI9',@6RT(#@4B!=(HO0V]U;G0@,2 M/CX@"F5N9&]B:@HT(#@;V)J"CP\"B]4>7!E("]086=E(HO4&%R96YT(#,@ M,"!2(HO365D:6%";W@@6SN,#P,"P+CP,#@-CY+C@X,C,@,S(V+C(P M-#%=(HO0V]N=&5N=',@-2P(%(@"B]297-O=7)C97,@/#P@"B]83V)J96-T M(#P\"B]);3$@-RP(%(@/CX+U!R;V-3970@6RO26UA9V5"(%T_/CX_/CX_ M96YD;V)J"C4@,"!O8FH_/#P@"B],96YG=&@@-BP(%(@"B^/@IS=')E86T_ M<2@-CY+C@X,C,@,"XP,#P(#N,#P,"S,C8N,CT,2P+CP,#@,"XP M,#P(&-M("]);3$@1&\@40H96YD<W1R96%M"F5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q-BP,#P,"!N(HP,#P,#P,#8X M(#P,#P(&X@"CP,#P,#R,3<@,#P,#@;B,#P,#P,#(X,2P,#P M,"!N(HP,#P,#P-#4W(#P,#P(&X@"CP,#P,#U-S4@,#P,#@;B` M,#P,#P,#4Y,RP,#P,"!N(HP,#P,#R.3,U(#P,#P(&X@"G1R86EL M97(*/#P*+U-I>F4@.0HO4F]O="Q(#@4B+TEN9F\@,B`P(%(@"B])1%L\ M-C<T-3A"-D)#-C(S-T(S,C8Y.3@S0S8T-S,T.#,S-C8^/#8W-#4X0C9"0S8R M,S=",S(V.3DX,T,V-#<S-#@S,S8V/ET/CX<W1A<G1X<F5F"C(Y-34)25%

3T8*

` end

Keywords: uuencode Migrated-From: http://trac.roundcube.net/ticket/1485839

rcubetrac commented 15 years ago

Comment by @alecpl on 7 May 2009 17:34 UTC

Attach sample message, please.

rcubetrac commented 15 years ago

Owner changed by @alecpl on 7 May 2009 17:34 UTC

=> none

rcubetrac commented 15 years ago

Milestone changed by @alecpl on 7 May 2009 17:34 UTC

later => 0.2.2

rcubetrac commented 15 years ago

Comment by Lazlo on 12 May 2009 08:37 UTC

Tested mail, works in Thunderbird, but doesn't show up correctly in Roundcube. (Running on trunk)

rcubetrac commented 15 years ago

Comment by @alecpl on 13 May 2009 07:10 UTC

Fixed in 1c5be6f7.

rcubetrac commented 15 years ago

Status changed by @alecpl on 13 May 2009 07:10 UTC

new => closed

rcubetrac commented 15 years ago

Comment by MKelma on 13 May 2009 09:30 UTC

thank you - working now. but it produces some error in log files: 11:26:04 PHP Warning: convert_uudecode() href='function.convert-uudecode'>function.convert-uudecode: The given parameter is not a valid uuencoded string in /..path../program/lib/imap.inc on line 2424

rcubetrac commented 15 years ago

Comment by @alecpl on 13 May 2009 10:08 UTC

Fixed in 67480442.

rcubetrac commented 15 years ago

Comment by MKelma on 13 May 2009 12:25 UTC

whoooa![record.... thanks.[BR] working now as expected.

rcubetrac commented 15 years ago

Comment by MKelma on 13 May 2009 21:43 UTC

above testmail with uuencoded word-file does not work in RC[[BR]] works in thunderbird etc...

rcubetrac commented 15 years ago

Status changed by MKelma on 13 May 2009 21:43 UTC

closed => reopened

rcubetrac commented 15 years ago

Comment by @alecpl on 14 May 2009 06:39 UTC

Fixed in b31a0af1.

rcubetrac commented 15 years ago

Status changed by @alecpl on 14 May 2009 06:39 UTC

reopened => closed

rcubetrac commented 14 years ago

Comment by @alecpl on 30 Mar 2010 10:18 UTC

http://www.roundcubeforum.net/5-release-support/17-pending-issues/6435-error-received-attachment.html[[BR]] Inline attachments in plain text body of non-MIME message are not handled.

rcubetrac commented 14 years ago

Status changed by @alecpl on 30 Mar 2010 10:18 UTC

closed => reopened

rcubetrac commented 14 years ago

Milestone changed by @alecpl on 30 Mar 2010 10:18 UTC

0.2.2 => 0.4-beta

rcubetrac commented 14 years ago

Comment by @alecpl on 28 May 2010 09:38 UTC

Fixed in d311d809.

rcubetrac commented 14 years ago

Status changed by @alecpl on 28 May 2010 09:38 UTC

reopened => closed

rcubetrac commented 14 years ago

Comment by towa48 on 12 Aug 2010 10:10 UTC

Guys i have a spaces in uuencoded files (pdf)! Attached file visible in Thunderbird, but doesn't show up correctly in Roundcube (4.0 stable).

But I have blank page if I edit regexp (rcube_message.php) from

$uu_regexp = '/begin [([^\n](0-7]{3,4})+)\n(([= '/begin [0-7](\x21-\x7E]{0,65}\n)+)`\nend/s';

to

$uu_regexp){3,4} ([^\n]+)\n(([\x20-\x7E]{0,65}\n)+)`\nend/s';

Looks like preg_match_all() get a error, but error log is empty. Help pls

Apache 2.2.9 PHP 5.2.6-1 Roundcube 4.0 stable

rcubetrac commented 14 years ago

Comment by @alecpl on 12 Aug 2010 10:13 UTC

Attach sample message.

rcubetrac commented 14 years ago

Comment by towa48 on 12 Aug 2010 10:35 UTC

sry, i cant. message contains personal data

...
Date: Thu, 12 Aug 2010 06:57:29 +0100
Message-ID: <xxx@intldn.manfinancial.net>
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2757
X-OriginalArrivalTime: 12 Aug 2010 05:57:30.0048 (UTC) FILETIME=[666 20100811CS60800730.pdf
M)5!$1BTQ+C,*):T*,2 P(&](3FC5D400:01CB39E3]

begin)B:@H\/ HO5'EP92 O0V%T86QO9PHO4&%G97,@
M,S0@,"!2"B]/=71L:6YE<R S-2 P(%(*+U!A9V5-;V1E("]5<V5/=71L:6YE
M<R *+U9I97=E<E!R969E<F5N8V5S(#(@,"!2"B]/<&5N06-T:6]N(%LP("]8
...
...
...
M138U-C@^70HO26YF;R R,2 P(%(*/CX*<W1A<G1X<F5F"C$X,38U,@HE)45/
"1@H`
`
end

If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. http://xxx.com - for important additional terms relating to this e-mail.
rcubetrac commented 14 years ago

Comment by @alecpl on 12 Aug 2010 11:14 UTC

If've checked on wikipedia ;) Looks you're right about the change in regexp. Some implementations are using spaces. If you got a blank page there must an error message in the log.

rcubetrac commented 14 years ago

Comment by towa48 on 12 Aug 2010 12:51 UTC

I think this is PCRE limit http://www.pcre.org/pcre.txt

The  maximum length of a compiled pattern is 65539 (sic) bytes if PCRE is compiled with the default internal linkage size of 2.

I think I need other algorithm for big files.

rcubetrac commented 14 years ago

Comment by towa48 on 12 Aug 2010 16:11 UTC

Ok. My internal linkage size is 1 (8 KBytes) and preg_match_all() show a blank page. This is my alternative function

    function uu_decode(&$part)
    {
        // @TODO: messages may be huge, hadle body via file
        if (!isset($part->body))
        $part->body = $this->imap->get_message_part($this->uid, $part->mime_id, $part);

        $parts = array();
        /* UUDECODE MOD */
        $uu_regexp = '/begin [([^\n](0-7]{3,4})+)\n/s';
        if (preg_match_all($uu_regexp, $part->body, $matches, PREG_SET_ORDER)) {

            // update message content-type
        $part->ctype_primary   = 'multipart';
        $part->ctype_secondary = 'mixed';
        $part->mimetype        = $part->ctype_primary . '/' . $part->ctype_secondary;

            $uu_endstring = "`\nend\n";

            // foreach attachments
            foreach ($matches as $pid => $att) {

                $startpos = strpos($part->body, $att[+ strlen($att[1](1]))) + 1; // "\n"
                $endpos = strpos($part->body, $uu_endstring);
                $filebody = substr($part->body, $startpos, $endpos-$startpos);

                // remove attachments bodies from the message body
                $part->body = substr_replace($part->body, "", $startpos, $endpos+strlen($uu_endstring)-$startpos);

                $uupart = new rcube_message_part;

                $uupart->filename = trim($att[= 'stream';
                $uupart->body     = convert_uudecode($filebody);
                $uupart->size     = strlen($uupart->body);
                $uupart->mime_id  = 'uu.' . $part->mime_id . '.' . $pid;

                $ctype = rc_mime_content_type($uupart->body, $uupart->filename, 'application/octet-stream', true);
                $uupart->mimetype = $ctype;
                list($uupart->ctype_primary, $uupart->ctype_secondary) = explode('/', $ctype);

                $parts[](1]);
                $uupart->encoding) = $uupart;
                unset($matches[$pid]);
            }

            // remove attachments headers from the message body
            $part->body = preg_replace($uu_regexp, '', $part->body);
        }
        /* END UUDECODE MOD */

        return $parts;
    }