[Svn] r2280 - in trunk/roundcubemail: . program/lib

trac at roundcube.net trac at roundcube.net
Fri Feb 6 20:04:46 CET 2009


Author: alec
Date: 2009-02-06 13:04:45 -0600 (Fri, 06 Feb 2009)
New Revision: 2280

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/lib/imap.inc
Log:
- Fix some base64 encoded attachments handling (#1485725)


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2009-02-06 16:33:46 UTC (rev 2279)
+++ trunk/roundcubemail/CHANGELOG	2009-02-06 19:04:45 UTC (rev 2280)
@@ -5,6 +5,7 @@
 ----------
 - Fix pressing select all/unread multiple times (#1485723)
 - Fix selecting all unread does not honor new messages (#1485724)
+- Fix some base64 encoded attachments handling (#1485725)
 
 2009/02/05 (alec)
 ----------

Modified: trunk/roundcubemail/program/lib/imap.inc
===================================================================
--- trunk/roundcubemail/program/lib/imap.inc	2009-02-06 16:33:46 UTC (rev 2279)
+++ trunk/roundcubemail/program/lib/imap.inc	2009-02-06 19:04:45 UTC (rev 2280)
@@ -2508,7 +2508,8 @@
         		$len      = $to - $from;
 	                $sizeStr  = substr($line, $from, $len);
         		$bytes    = (int)$sizeStr;
-
+			$prev	  = '';
+			
         		while ($bytes > 0) {
     		                $line      = iil_ReadLine($fp, 1024);
             			$len       = strlen($line);
@@ -2518,14 +2519,27 @@
 		                }
             			$bytes -= strlen($line);
 
+				$line = rtrim($line, "\t\r\n\0\x0B");
+
 		                if ($mode == 1) {
 					if ($file)
-						fwrite($file, rtrim($line, "\t\r\n\0\x0B") . "\n");
+						fwrite($file, $line . "\n");
             			        else
-						$result .= rtrim($line, "\t\r\n\0\x0B") . "\n";
+						$result .= $line . "\n";
 		                } else if ($mode == 2) {
-            			        echo rtrim($line, "\t\r\n\0\x0B") . "\n";
+            			        echo $line . "\n";
 		                } else if ($mode == 3) {
+					// create chunks with proper length for base64 decoding
+					$line = $prev.$line;
+					$length = strlen($line);
+					if ($length % 4) {
+						$length = floor($length / 4) * 4;
+						$prev = substr($line, $length);
+						$line = substr($line, 0, $length);
+					}
+					else
+						$prev = '';
+
 					if ($file)
 						fwrite($file, base64_decode($line));
             				else

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list