[Svn] r4207 - trunk/roundcubemail/program/include

trac at roundcube.net trac at roundcube.net
Wed Nov 10 09:15:41 CET 2010


Author: alec
Date: 2010-11-10 02:15:41 -0600 (Wed, 10 Nov 2010)
New Revision: 4207

Modified:
   trunk/roundcubemail/program/include/rcube_imap_generic.php
Log:
- Fix handling of message bodies (quoted-printable encoded) with NULL characters (#1486189)


Modified: trunk/roundcubemail/program/include/rcube_imap_generic.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_imap_generic.php	2010-11-09 21:18:53 UTC (rev 4206)
+++ trunk/roundcubemail/program/include/rcube_imap_generic.php	2010-11-10 08:15:41 UTC (rev 4207)
@@ -2080,6 +2080,7 @@
 		        }
             	$bytes -= $len;
 
+                // BASE64
 		        if ($mode == 1) {
 					$line = rtrim($line, "\t\r\n\0\x0B");
 					// create chunks with proper length for base64 decoding
@@ -2092,40 +2093,30 @@
 					}
 					else
 						$prev = '';
-
-					if ($file)
-						fwrite($file, base64_decode($line));
-            		else if ($print)
-						echo base64_decode($line);
-					else
-						$result .= base64_decode($line);
+					$line = base64_decode($line);
+                // QUOTED-PRINTABLE
 				} else if ($mode == 2) {
 					$line = rtrim($line, "\t\r\0\x0B");
-					if ($file)
-						fwrite($file, quoted_printable_decode($line));
-            		else if ($print)
-						echo quoted_printable_decode($line);
-					else
-						$result .= quoted_printable_decode($line);
+                    $line = quoted_printable_decode($line);
+                    // Remove NULL characters (#1486189)
+                    $line = str_replace("\x00", '', $line);
+                // UUENCODE
 				} else if ($mode == 3) {
 					$line = rtrim($line, "\t\r\n\0\x0B");
 					if ($line == 'end' || preg_match('/^begin\s+[0-7]+\s+.+$/', $line))
 						continue;
-					if ($file)
-						fwrite($file, convert_uudecode($line));
-            		else if ($print)
-						echo convert_uudecode($line);
-					else
-						$result .= convert_uudecode($line);
+                    $line = convert_uudecode($line);
+                // default
 				} else {
-					$line = rtrim($line, "\t\r\n\0\x0B");
-					if ($file)
-						fwrite($file, $line . "\n");
-            		else if ($print)
-						echo $line . "\n";
-					else
-						$result .= $line . "\n";
+					$line = rtrim($line, "\t\r\n\0\x0B") . "\n";
 				}
+
+    			if ($file)
+					fwrite($file, $line);
+           		else if ($print)
+					echo $line;
+				else
+					$result .= $line;
         	}
     	}
 

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



More information about the Svn mailing list