From 7fc0b94450df4ac91de1aa7350574974e2b0a21b Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 05 Oct 2009 05:26:33 -0400
Subject: [PATCH] - improve Content-type header parsing

---
 program/lib/imap.inc |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 437ea59..9d896ff 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -1592,13 +1592,10 @@
 						$result[$id]->encoding = $string;
 						break;
 					case 'content-type':
-						$ctype_parts = explode(";", $string);
+						$ctype_parts = preg_split('/[; ]/', $string);
 						$result[$id]->ctype = array_shift($ctype_parts);
-						foreach ($ctype_parts as $ctype_add) {
-							if (preg_match('/charset="?([a-z0-9\-\.\_]+)"?/i',
-								$ctype_add, $regs)) {
-								$result[$id]->charset = $regs[1];
-							}
+						if (preg_match('/charset\s*=\s*"?([a-z0-9\-\.\_]+)"?/i', $string, $regs)) {
+							$result[$id]->charset = $regs[1];
 						}
 						break;
 					case 'in-reply-to':

--
Gitblit v1.9.1