From 3625820490496633a180ee57035f11b86c181798 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 13 Jan 2011 14:49:55 +0000 Subject: [PATCH] Fixes for parsing invalid HTML without tag ends. The code in wxHtmlParser supposed in many places that a '<' character must be always followed by a '>' one and could create (and sometimes dereference) invalid iterators if this wasn't the case resulting in asserts from MSVC debug CRT and possibly crashes. Fix this by ensuring that only valid iterators are used and add a trivial unit test for wxHtmlParser which checks that it can parse invalid HTML without crashing. Closes #12869. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66678 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/html/htmlpars.cpp | 4 +- src/html/htmltag.cpp | 31 ++++++++++---- tests/Makefile.in | 4 ++ tests/html/htmlparser.cpp | 75 ++++++++++++++++++++++++++++++++++ tests/makefile.bcc | 4 ++ tests/makefile.gcc | 4 ++ tests/makefile.vc | 4 ++ tests/makefile.wat | 4 ++ tests/test.bkl | 1 + tests/test_test_gui.dsp | 4 ++ tests/test_vc7_test_gui.vcproj | 3 ++ tests/test_vc8_test_gui.vcproj | 4 ++ tests/test_vc9_test_gui.vcproj | 4 ++ 13 files changed, 137 insertions(+), 9 deletions(-) create mode 100644 tests/html/htmlparser.cpp diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index 38c0680c23..ed99a443b6 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -227,7 +227,7 @@ void wxHtmlParser::CreateDOMSubTree(wxHtmlTag *cur, else { while (i < end_pos && *i != wxT('>')) ++i; - textBeginning = i+1; + textBeginning = i < end_pos ? i+1 : i; } } else ++i; @@ -958,7 +958,7 @@ wxHtmlParser::SkipCommentTag(wxString::const_iterator& start, wxString::const_iterator p = start; // comments begin with "