diff --git a/include/class.forms.php b/include/class.forms.php
index 5253fa55affb06552035de3e40e3fd56b45ad816..dd5477cc966d1f5650c347b1c461f75543dc7275 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -1221,7 +1221,7 @@ class ThreadEntryWidget extends Widget {
             && !$cfg->allowAttachmentsOnlogin())
             || ($cfg->allowAttachmentsOnlogin()
                 && ($thisclient && $thisclient->isValid()))) { ?>
-        <div class="clear"><div>
+        <div class="clear"></div>
         <hr/>
         <div><strong style="padding-right:1em;vertical-align:top">Attachments: </strong>
         <div style="display:inline-block">
diff --git a/include/class.mailparse.php b/include/class.mailparse.php
index 703258b5632f4e835d21c1a7368e70042c76987f..22bb6ad418997c8a55d5810d9db78d811bde7ad1 100644
--- a/include/class.mailparse.php
+++ b/include/class.mailparse.php
@@ -275,7 +275,8 @@ class Mail_Parse {
                 return $p->parts[0]->headers;
             // Handle rfc1892 style bounces
             if (strtolower($ctype) === 'text/rfc822-headers') {
-                $T = new Mail_mimeDecode($p->body . "\n\nIgnored");
+                $body = $p->body . "\n\nIgnored";
+                $T = new Mail_mimeDecode($body);
                 if ($struct = $T->decode())
                     return $struct->headers;
             }
diff --git a/include/class.thread.php b/include/class.thread.php
index 1981575e05add07d61585aa60319d37444f86c0a..8ba433c8f8e37f0d99bbecaa62c12170d7f131a0 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -1048,7 +1048,7 @@ Class ThreadEntry {
                 // content-id will be discarded, only the unique hash-code
                 // will be available to retrieve the image later
                 if ($a['cid'] && $a['key']) {
-                    $body = preg_replace('/src=("|\'|\b)(?:cid:)?'.$a['cid'].'\1/i',
+                    $body = preg_replace('/src=("|\'|\b)(?:cid:)?'.preg_quote($a['cid']).'\1/i',
                         'src="cid:'.$a['key'].'"', $body);
                 }
             }