From 9d9623462ab144f9013b1f7ac85667e186f6c0d8 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 23 Oct 2014 05:09:35 -0400
Subject: [PATCH] Fix handling of base64-encoded attachments with extra spaces (#1490111)

---
 CHANGELOG                                    |    1 +
 program/lib/Roundcube/rcube_imap_generic.php |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index f5ac7a1..e905a8b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -57,6 +57,7 @@
 - Fix font style display issue in HTML messages with styled <span> elements (#1490101)
 - Fix download of attachments that are part of TNEF message (#1490091)
 - Fix handling of uuencoded messages if messages_cache is enabled (#1490108)
+- Fix handling of base64-encoded attachments with extra spaces (#1490111)
 
 RELEASE 1.0.3
 -------------
diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index 734a931..7c1166f 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -2675,7 +2675,7 @@
 
                     // BASE64
                     if ($mode == 1) {
-                        $line = rtrim($line, "\t\r\n\0\x0B");
+                        $line = preg_replace('|[^a-zA-Z0-9+=/]|', '', $line);
                         // create chunks with proper length for base64 decoding
                         $line = $prev.$line;
                         $length = strlen($line);

--
Gitblit v1.9.1