diff --git a/trac/wiki/formatter.py b/trac/wiki/formatter.py
--- a/trac/wiki/formatter.py
+++ b/trac/wiki/formatter.py
@@ -79,6 +79,7 @@
         self.macro_provider = None
 
         builtin_processors = {'html': self._html_processor,
+                              'htmlcomment': self._htmlcomment_processor,
                               'default': self._default_processor,
                               'comment': self._comment_processor,
                               'div': self._div_processor,
@@ -130,6 +131,12 @@
             line = unicode(text).splitlines()[e.lineno - 1].strip()
             return system_message(_('HTML parsing error: %(message)s',
                                     message=escape(e.msg)), line)
+        
+    def _htmlcomment_processor(self, text):
+        if "--" in text:
+            return system_message(_('Error: Forbidden character sequence '
+                                    '"--" in htmlcomment wiki code block'))
+        return Markup('<!--\n%s-->\n' % text)
         
     def _elt_processor(self, eltname, format_to, text, args):
         elt = getattr(tag, eltname)(**args)
diff --git a/trac/wiki/tests/wiki-tests.txt b/trac/wiki/tests/wiki-tests.txt
--- a/trac/wiki/tests/wiki-tests.txt
+++ b/trac/wiki/tests/wiki-tests.txt
@@ -551,6 +551,66 @@
 <div>Click me</div>
 ------------------------------
  […]
+============================== HTML comment wiki processor
+Before
+{{{
+#!htmlcomment
+This is a comment <em>with embedded tags &amp; entities</em>
+}}}
+After
+------------------------------
+<p>
+Before
+</p>
+<!--
+This is a comment <em>with embedded tags &amp; entities</em>
+-->
+<p>
+After
+</p>
+------------------------------
+Before
+ […]
+After
+============================== HTML comment wiki processor, comment ends with "-"
+Before
+{{{
+#!htmlcomment
+This comment ends with -
+}}}
+After
+------------------------------
+<p>
+Before
+</p>
+<!--
+This comment ends with -
+-->
+<p>
+After
+</p>
+------------------------------
+Before
+ […]
+After
+============================== HTML comment wiki processor, comment contains "--"
+Before
+{{{
+#!htmlcomment
+The character sequence -- is not allowed in comments
+}}}
+After
+------------------------------
+<p>
+Before
+</p>
+<div class="system-message"><strong>Error: Forbidden character sequence "--" in htmlcomment wiki code block</strong></div><p>
+After
+</p>
+------------------------------
+Before
+ […]
+After
 ============================== div and span wiki processors
 And now it's [[span('''TIME FOR BED!,class=important)]]. Really.
 {{{

