Index: htmlcorrector.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/htmlcorrector/htmlcorrector.module,v
retrieving revision 1.12
diff -u -p -r1.12 htmlcorrector.module
--- htmlcorrector.module	27 Jan 2007 01:02:02 -0000	1.12
+++ htmlcorrector.module	3 Jun 2008 22:39:01 -0000
@@ -25,7 +25,7 @@ function _htmlcorrector_process($text) {
   $singleuse = array('base', 'meta', 'link', 'hr', 'br', 'param', 'img', 'area', 'input', 'col', 'frame');
 
   // Properly entify angles
-  $text = preg_replace('!<([^a-zA-Z/])!', '&lt;\1', $text);
+  $text = preg_replace('@<([^a-zA-Z!/])@', '&lt;\1', $text);
 
   // Splits tags from text
   $split = preg_split('/<([^>]+?)>/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -59,13 +59,16 @@ function _htmlcorrector_process($text) {
         if (count($stack) && ($stack[0] == $tagname) && in_array($stack[0], $nonesting)) {
           $output .= '</'. array_shift($stack) .'>';
         }
-        // Push non-single-use tags onto the stack
-        if (!in_array($tagname, $singleuse)) {
-          array_unshift($stack, $tagname);
-        }
-        // Add trailing slash to single-use tags as per X(HT)ML.
-        else {
-          $value = rtrim($value, ' /') . ' /';
+        // Ensure we're not closing a HTML comment.
+        if ($tagname{0} != '!') {
+          // Push non-single-use tags onto the stack
+          if (!in_array($tagname, $singleuse)) {
+            array_unshift($stack, $tagname);
+          }
+          // Add trailing slash to single-use tags as per X(HT)ML.
+          else {
+            $value = rtrim($value, ' /') . ' /';
+          }
         }
         $output .= '<'. $value .'>';
       }
