fixed wxHTML parser to not assert on invalid HTML input (unclosed tags)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -126,13 +126,11 @@ public:
|
|||||||
// returns ending position of _internal_ block of text as iterator
|
// returns ending position of _internal_ block of text as iterator
|
||||||
// into parser's source string (see wxHtmlParser::GetSource()):
|
// into parser's source string (see wxHtmlParser::GetSource()):
|
||||||
// bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
|
// bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
|
||||||
wxString::const_iterator GetEndIter1() const
|
wxString::const_iterator GetEndIter1() const { return m_End1; }
|
||||||
{ wxASSERT(m_hasEnding); return m_End1; }
|
|
||||||
// returns end position 2 as iterator
|
// returns end position 2 as iterator
|
||||||
// into parser's source string (see wxHtmlParser::GetSource()):
|
// into parser's source string (see wxHtmlParser::GetSource()):
|
||||||
// bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
|
// bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
|
||||||
wxString::const_iterator GetEndIter2() const
|
wxString::const_iterator GetEndIter2() const { return m_End2; }
|
||||||
{ wxASSERT(m_hasEnding); return m_End2; }
|
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_2_8
|
#if WXWIN_COMPATIBILITY_2_8
|
||||||
// use GetBeginIter(), GetEndIter1() and GetEndIter2() instead
|
// use GetBeginIter(), GetEndIter1() and GetEndIter2() instead
|
||||||
|
@@ -246,9 +246,27 @@ void wxHtmlTagsCache::QueryTag(const wxString::const_iterator& at,
|
|||||||
}
|
}
|
||||||
while (Cache()[m_CachePos].Key != at);
|
while (Cache()[m_CachePos].Key != at);
|
||||||
}
|
}
|
||||||
*end1 = Cache()[m_CachePos].End1;
|
|
||||||
*end2 = Cache()[m_CachePos].End2;
|
switch ( Cache()[m_CachePos].type )
|
||||||
*hasEnding = (Cache()[m_CachePos].type == wxHtmlCacheItem::Type_Normal);
|
{
|
||||||
|
case wxHtmlCacheItem::Type_Normal:
|
||||||
|
*end1 = Cache()[m_CachePos].End1;
|
||||||
|
*end2 = Cache()[m_CachePos].End2;
|
||||||
|
*hasEnding = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxHtmlCacheItem::Type_EndingTag:
|
||||||
|
wxFAIL_MSG("QueryTag called for ending tag - can't be");
|
||||||
|
// but if it does happen, fall through, better than crashing
|
||||||
|
|
||||||
|
case wxHtmlCacheItem::Type_NoMatchingEndingTag:
|
||||||
|
// If input HTML is invalid and there's no closing tag for this
|
||||||
|
// one, pretend that it runs all the way to the end of input
|
||||||
|
*end1 = inputEnd;
|
||||||
|
*end2 = inputEnd;
|
||||||
|
*hasEnding = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user