From 4609ee2ef8b7787ba5241602b38759ff32e6777d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 8 Apr 2007 21:02:03 +0000 Subject: [PATCH] fix the problem with parsing HTML comments (closes bug 1116708; based on patch 1168583) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45336 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/html/htmlpars.h | 7 ++++ src/html/htmlpars.cpp | 79 +++++++++++++++++++++++++++----------- src/html/htmltag.cpp | 13 +++++-- 3 files changed, 72 insertions(+), 27 deletions(-) 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 "