diff --git a/include/wx/html/htmlpars.h b/include/wx/html/htmlpars.h
index 96c357639f..b5c6c6830f 100644
--- a/include/wx/html/htmlpars.h
+++ b/include/wx/html/htmlpars.h
@@ -128,6 +128,13 @@ public:
// Returns entity parser object, used to substitute HTML &entities;
wxHtmlEntitiesParser *GetEntitiesParser() const { return m_entitiesParser; }
+ // Returns true if the tag starting at the given position is a comment tag
+ //
+ // p should point to '<' character and is modified to point to the closing
+ // '>' of the end comment tag if this is indeed a comment
+ static bool
+ SkipCommentTag(wxString::const_iterator& p, wxString::const_iterator end);
+
protected:
// DOM structure
void CreateDOMTree();
diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp
index 7efb69af34..ff9c189223 100644
--- a/src/html/htmlpars.cpp
+++ b/src/html/htmlpars.cpp
@@ -171,29 +171,11 @@ void wxHtmlParser::CreateDOMSubTree(wxHtmlTag *cur,
wxHtmlTextPiece(textBeginning, i - textBeginning));
// if it is a comment, skip it:
- if (i < end_pos-6 && m_Source.GetChar(i+1) == wxT('!') &&
- m_Source.GetChar(i+2) == wxT('-') &&
- m_Source.GetChar(i+3) == wxT('-'))
+ wxString::const_iterator iter = m_Source.begin() + i;
+ if ( SkipCommentTag(iter, m_Source.end()) )
{
- // Comments begin with "