diff --git a/include/class.format.php b/include/class.format.php
index 03216e4a061665b2b18a856f8bf95509f9dd5236..048b886b7913279b6414c904f3d7ab89eb5204e2 100644
--- a/include/class.format.php
+++ b/include/class.format.php
@@ -199,7 +199,7 @@ class Format {
     function safe_html($html) {
         // Remove HEAD and STYLE sections
         $html = preg_replace(
-            array(':<(head|style|script).+</\1>:is',   # <head> and <style> sections
+            array(':<(head|style|script).+?</\1>:is', # <head> and <style> sections
                   ':<!\[[^]<]+\]>:',            # <![if !mso]> and friends
                   ':<!DOCTYPE[^>]+>:',          # <!DOCTYPE ... >
                   ':<\?[^>]+>:',                # <?xml version="1.0" ... >