]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/htmlpars.cpp
Further refine of #15226: wxRichTextCtrl: Implement setting properties with undo...
[wxWidgets.git] / src / html / htmlpars.cpp
index 38c0680c232a5eb5507c41f2d7118c9862500dba..308df6922a82aab6dca3a5558968c4964983ffb1 100644 (file)
@@ -2,7 +2,6 @@
 // Name:        src/html/htmlpars.cpp
 // Purpose:     wxHtmlParser class (generic parser)
 // Author:      Vaclav Slavik
 // Name:        src/html/htmlpars.cpp
 // Purpose:     wxHtmlParser class (generic parser)
 // Author:      Vaclav Slavik
-// RCS-ID:      $Id$
 // Copyright:   (c) 1999 Vaclav Slavik
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) 1999 Vaclav Slavik
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -227,7 +226,7 @@ void wxHtmlParser::CreateDOMSubTree(wxHtmlTag *cur,
             else
             {
                 while (i < end_pos && *i != wxT('>')) ++i;
             else
             {
                 while (i < end_pos && *i != wxT('>')) ++i;
-                textBeginning = i+1;
+                textBeginning = i < end_pos ? i+1 : i;
             }
         }
         else ++i;
             }
         }
         else ++i;
@@ -919,11 +918,13 @@ bool wxMetaTagHandler::HandleTag(const wxHtmlTag& tag)
         return false;
     }
 
         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);
         if (content.Left(19) == wxT("text/html; charset="))
         {
             *m_retval = content.Mid(19);
@@ -957,12 +958,14 @@ wxHtmlParser::SkipCommentTag(wxString::const_iterator& start,
 
     wxString::const_iterator p = start;
 
 
     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
 
     // skip the start of the comment tag in any case, if we don't find the
     // closing tag we should ignore broken markup