Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.973 diff -u -r1.973 common.inc --- includes/common.inc 25 Aug 2009 15:39:13 -0000 1.973 +++ includes/common.inc 26 Aug 2009 00:15:51 -0000 @@ -1460,6 +1460,8 @@ ( <(?=[^a-zA-Z!/]) # a lone < | # or + # a comment + | # or <[^>]*(>|$) # a string that starts with a <, up until the > or the end of the string | # or > # just a > @@ -1498,7 +1500,7 @@ return '<'; } - if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) { + if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?|()$%', $string, $matches)) { // Seriously malformed return ''; } @@ -1506,11 +1508,20 @@ $slash = trim($matches[1]); $elem = &$matches[2]; $attrlist = &$matches[3]; + $comment = &$matches[4]; + + if ($comment) { + $elem = '!--'; + } if (!isset($allowed_html[strtolower($elem)])) { // Disallowed HTML element return ''; } + + if ($comment) { + return $comment; + } if ($slash != '') { return ""; Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.279 diff -u -r1.279 filter.module --- modules/filter/filter.module 25 Aug 2009 10:35:32 -0000 1.279 +++ modules/filter/filter.module 26 Aug 2009 00:15:51 -0000 @@ -824,11 +824,11 @@ // All block level tags $block = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|p|h[1-6]|hr)'; - // Split at
, ,  tags.
+  // Split at 
, ,  and comments tags.
   // We don't apply any processing to the contents of these tags to avoid messing
   // up code. We look for matched pairs and allow basic nesting. For example:
   // "processed 
 ignored  ignored 
processed" - $chunks = preg_split('@(]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + $chunks = preg_split('@(|]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // Note: PHP ensures the array consists of alternating delimiters and literals // and begins and ends with a literal (inserting NULL as required). $ignore = FALSE; @@ -837,7 +837,8 @@ foreach ($chunks as $i => $chunk) { if ($i % 2) { // Opening or closing tag? - $open = ($chunk[1] != '/'); + $open = ($chunk[1] != '/' || $chunk[1] != '!'); + $comment = (substr($chunk, 0, 4) == '