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);
                 }
             }