From fab43d2eb5c9d413a6fc097291a197094ed3dd99 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Mon, 18 Aug 2008 08:33:26 -0400
Subject: [PATCH] Better fix for bodystructure parsing (#1485280)

---
 program/lib/imap.inc |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 600b0d4..84d1b36 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -2576,11 +2576,11 @@
 				$line = iil_ReadLine($fp, 5000);
 				$line = iil_MultLine($fp, $line);
 				list(, $index, $cmd, $rest) = explode(' ', $line);
-				if ($cmd != 'FETCH' || $index == $id)
+				if ($cmd != 'FETCH' || $index == $id || preg_match("/^$key/", $line))
 					$result .= $line;
 			} while (!preg_match("/^$key/", $line));
 
-			$result = trim(substr($result, strpos($result, 'BODYSTRUCTURE')+13));
+			$result = trim(substr($result, strpos($result, 'BODYSTRUCTURE')+13, -(strlen($result)-strrpos($result, $key)+1)));
 		}
 	}
 	return $result;

--
Gitblit v1.9.1