// Name: src/html/htmlpars.cpp
// Purpose: wxHtmlParser class (generic parser)
// Author: Vaclav Slavik
-// RCS-ID: $Id$
// Copyright: (c) 1999 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
else
{
while (i < end_pos && *i != wxT('>')) ++i;
- textBeginning = i+1;
+ textBeginning = i < end_pos ? i+1 : i;
}
}
else ++i;
return false;
}
- if (tag.HasParam(wxT("HTTP-EQUIV")) &&
- tag.GetParam(wxT("HTTP-EQUIV")).IsSameAs(wxT("Content-Type"), false) &&
- tag.HasParam(wxT("CONTENT")))
+ wxString httpEquiv,
+ content;
+ if (tag.GetParamAsString(wxT("HTTP-EQUIV"), &httpEquiv) &&
+ httpEquiv.IsSameAs(wxT("Content-Type"), false) &&
+ tag.GetParamAsString(wxT("CONTENT"), &content))
{
- wxString content = tag.GetParam(wxT("CONTENT")).Lower();
+ content.MakeLower();
if (content.Left(19) == wxT("text/html; charset="))
{
*m_retval = content.Mid(19);
wxString::const_iterator p = start;
- // comments begin with "<!--" in HTML 4.0
- if ( p > end - 3 || *++p != '!' || *++p != '-' || *++p != '-' )
- {
- // not a comment at all
- return false;
- }
+ // Comments begin with "<!--" in HTML 4.0; anything shorter or not containing
+ // these characters is not a comment and we're not going to skip it.
+ if ( ++p == end || *p != '!' )
+ return false;
+ if ( ++p == end || *p != '-' )
+ return false;
+ if ( ++p == end || *p != '-' )
+ return false;
// skip the start of the comment tag in any case, if we don't find the
// closing tag we should ignore broken markup