Projects
Kolab:3.4
kolab-syncroton
kolab-syncroton-2.2.4-fix-recode-message-bounda...
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kolab-syncroton-2.2.4-fix-recode-message-boundary-handling.patch of Package kolab-syncroton (Revision 46)
Currently displaying revision
46
,
Show latest
commit 80ebec3f4600f99d1ac693cc15b03f20d8d4a75a Author: Aleksander Machniak <alec@alec.pl> Date: Thu Feb 6 15:55:57 2014 +0100 Fix issues in recode_message() - wrong boundaries handling diff --git a/lib/kolab_sync_message.php b/lib/kolab_sync_message.php index 79ac8d9..026d557 100644 --- a/lib/kolab_sync_message.php +++ b/lib/kolab_sync_message.php @@ -297,15 +297,15 @@ class kolab_sync_message $hdrs = self::parse_headers($headers); // multipart message - if (preg_match('/boundary="?([a-z0-9-_]+)"?/i', $hdrs['Content-Type'], $matches)) { + if (preg_match('/boundary="?([a-z0-9-\'\(\)+_\,\.\/:=\? ]+)"?/i', $hdrs['Content-Type'], $matches)) { $boundary = '--' . $matches[1]; $message = explode($boundary, $message); for ($x=1, $parts = count($message) - 1; $x<$parts; $x++) { - $message[$x] = "\r\n" . self::recode_message($message[$x]); + $message[$x] = "\r\n" . self::recode_message(ltrim($message[$x])); } - return $headers . "\r\n\r\n" . implode($boundary, $message); + return $headers . "\r\n\r\n" . implode($boundary , $message); } // single part diff --git a/tests/message.php b/tests/message.php index 19e1901..a49c5d1 100644 --- a/tests/message.php +++ b/tests/message.php @@ -135,4 +135,17 @@ class message extends PHPUnit_Framework_TestCase $this->assertEquals($result, $message); } + + /** + * Test recoding the message + */ + function test_recode_message_4() + { + $source = file_get_contents(TESTS_DIR . '/src/mail.recode4'); + $result = file_get_contents(TESTS_DIR . '/src/mail.recode4.out'); + + $message = kolab_sync_message::recode_message($source); + + $this->assertEquals($result, $message); + } } diff --git a/tests/src/mail.recode2.out b/tests/src/mail.recode2.out index ff4c323..be03aae 100644 --- a/tests/src/mail.recode2.out +++ b/tests/src/mail.recode2.out @@ -9,7 +9,6 @@ Content-Type: multipart/mixed; This is a multi-part message in MIME format. --------------000801030509090203070207 - Content-Type: multipart/alternative; boundary="------------060305070900000101080707" @@ -31,7 +30,6 @@ ZSBBZHZlbnRzZ3L832U8YnI+DQogIDwvYm9keT4NCjwvaHRtbD4= --------------060305070900000101080707-- --------------000801030509090203070207 - Content-Type: application/pdf; name="Weihnachtsbrief13.pdf" Content-Transfer-Encoding: base64 diff --git a/tests/src/mail.recode4 b/tests/src/mail.recode4 new file mode 100644 index 0000000..624766e --- /dev/null +++ b/tests/src/mail.recode4 @@ -0,0 +1,47 @@ +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="=_421c567043d5df058671910ddb659fc5" +Date: Thu, 06 Feb 2014 13:59:33 +0000 +From: alec <test@test.cc> +To: <test2@test.cc> +Subject: test html + image +Message-ID: <6c821c802bc5293e179f9bcb5d4d8279@klab.cc> +User-Agent: Roundcube Webmail/1.0-git + +--=_421c567043d5df058671910ddb659fc5 +Content-Transfer-Encoding: 8bit +Content-Type: text/plain; charset=UTF-8 + + + +test message with inline image żąść + + +--=_421c567043d5df058671910ddb659fc5 +Content-Type: multipart/related; + boundary="=_61b68141aaee8dc5b321e6059b43bb78" + +--=_61b68141aaee8dc5b321e6059b43bb78 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; charset=UTF-8 + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> +<html><body style=3D'font-size: 10pt; font-family: Verdana,Geneva,sans-seri= +f'> +<p>test message with inline image =C5=BC=C4=85=C5=9B=C4=87</p> +<p><img src=3D"cid:139169517352f395455c016176663627@test.cc" alt=3D"logo.gif" /></p> +</body></html> + +--=_61b68141aaee8dc5b321e6059b43bb78 +Content-Transfer-Encoding: base64 +Content-ID: <139169517352f395455c016176663627@test.cc> +Content-Type: image/jpeg; + name=logo.gif +Content-Disposition: inline; + filename=logo.gif; + size=25745 + +/9j/4AAQSkZJRgABAgEASABIAAD/4QqARXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUA +--=_61b68141aaee8dc5b321e6059b43bb78-- + +--=_421c567043d5df058671910ddb659fc5-- diff --git a/tests/src/mail.recode4.out b/tests/src/mail.recode4.out new file mode 100644 index 0000000..e86db3f --- /dev/null +++ b/tests/src/mail.recode4.out @@ -0,0 +1,43 @@ +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="=_421c567043d5df058671910ddb659fc5" +Date: Thu, 06 Feb 2014 13:59:33 +0000 +From: alec <test@test.cc> +To: <test2@test.cc> +Subject: test html + image +Message-ID: <6c821c802bc5293e179f9bcb5d4d8279@klab.cc> +User-Agent: Roundcube Webmail/1.0-git + +--=_421c567043d5df058671910ddb659fc5 +Content-Transfer-Encoding: base64 +Content-Type: text/plain; charset=UTF-8 + +IA0KDQp0ZXN0IG1lc3NhZ2Ugd2l0aCBpbmxpbmUgaW1hZ2UgxbzEhcWbxIc= +--=_421c567043d5df058671910ddb659fc5 +Content-Type: multipart/related; + boundary="=_61b68141aaee8dc5b321e6059b43bb78" + +--=_61b68141aaee8dc5b321e6059b43bb78 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; charset=UTF-8 + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> +<html><body style=3D'font-size: 10pt; font-family: Verdana,Geneva,sans-seri= +f'> +<p>test message with inline image =C5=BC=C4=85=C5=9B=C4=87</p> +<p><img src=3D"cid:139169517352f395455c016176663627@test.cc" alt=3D"logo.gif" /></p> +</body></html> + +--=_61b68141aaee8dc5b321e6059b43bb78 +Content-Transfer-Encoding: base64 +Content-ID: <139169517352f395455c016176663627@test.cc> +Content-Type: image/jpeg; + name=logo.gif +Content-Disposition: inline; + filename=logo.gif; + size=25745 + +/9j/4AAQSkZJRgABAgEASABIAAD/4QqARXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUA +--=_61b68141aaee8dc5b321e6059b43bb78-- + +--=_421c567043d5df058671910ddb659fc5--
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.