Improve the <!DOCTYPE> parsing. b=363883 r=mrbkap sr=jst
authormats.palmgren@bredband.net
Tue, 08 May 2007 05:19:32 -0700
changeset 1280 249ecaedde25a8156e951f25cb4a8c34e73496f6
parent 1279 4fd338273fc3bedffe132d8a893e3a4ccfd5323e
child 1281 4e1999a4b7dbb34699732477d55b594aba27f750
push idunknown
push userunknown
push dateunknown
reviewersmrbkap, jst
bugs363883
milestone1.9a5pre
Improve the <!DOCTYPE> parsing. b=363883 r=mrbkap sr=jst
parser/htmlparser/src/nsHTMLTokenizer.cpp
parser/htmlparser/src/nsParser.cpp
--- a/parser/htmlparser/src/nsHTMLTokenizer.cpp
+++ b/parser/htmlparser/src/nsHTMLTokenizer.cpp
@@ -1115,17 +1115,17 @@ nsHTMLTokenizer::ConsumeSpecialMarkup(PR
 {
   // Get the "!"
   aScanner.GetChar(aChar);
 
   nsresult result = NS_OK;
   nsAutoString theBufCopy;
   aScanner.Peek(theBufCopy, 20);
   ToUpperCase(theBufCopy);
-  PRInt32 theIndex = theBufCopy.Find("DOCTYPE");
+  PRInt32 theIndex = theBufCopy.Find("DOCTYPE", PR_FALSE, 0, 0);
   nsTokenAllocator* theAllocator = this->GetTokenAllocator();
 
   if (theIndex == kNotFound) {
     if ('[' == theBufCopy.CharAt(0)) {
       aToken = theAllocator->CreateTokenOfType(eToken_cdatasection,
                                                eHTMLTag_comment);
     } else if (StringBeginsWith(theBufCopy, NS_LITERAL_STRING("ELEMENT")) ||
                StringBeginsWith(theBufCopy, NS_LITERAL_STRING("ATTLIST")) ||
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -486,17 +486,17 @@ ParseDocTypeDecl(const nsString &aBuffer
   PRInt32 theIndex = 0;
   do {
     theIndex = aBuffer.FindChar('<', theIndex);
     if (theIndex == kNotFound) break;
     PRUnichar nextChar = aBuffer.CharAt(theIndex+1);
     if (nextChar == PRUnichar('!')) {
       PRInt32 tmpIndex = theIndex + 2;
       if (kNotFound !=
-          (theIndex=aBuffer.Find("DOCTYPE", PR_TRUE, tmpIndex, 1))) {
+          (theIndex=aBuffer.Find("DOCTYPE", PR_TRUE, tmpIndex, 0))) {
         haveDoctype = PR_TRUE;
         theIndex += 7; // skip "DOCTYPE"
         break;
       }
       theIndex = ParsePS(aBuffer, tmpIndex);
       theIndex = aBuffer.FindChar('>', theIndex);
     } else if (nextChar == PRUnichar('?')) {
       theIndex = aBuffer.FindChar('>', theIndex);
@@ -505,21 +505,21 @@ ParseDocTypeDecl(const nsString &aBuffer
     }
   } while (theIndex != kNotFound);
 
   if (!haveDoctype)
     return PR_TRUE;
   *aResultFlags |= PARSE_DTD_HAVE_DOCTYPE;
 
   theIndex = ParsePS(aBuffer, theIndex);
-  theIndex = aBuffer.Find("HTML", PR_TRUE, theIndex, 1);
+  theIndex = aBuffer.Find("HTML", PR_TRUE, theIndex, 0);
   if (kNotFound == theIndex)
     return PR_FALSE;
   theIndex = ParsePS(aBuffer, theIndex+4);
-  PRInt32 tmpIndex = aBuffer.Find("PUBLIC", PR_TRUE, theIndex, 1);
+  PRInt32 tmpIndex = aBuffer.Find("PUBLIC", PR_TRUE, theIndex, 0);
 
   if (kNotFound != tmpIndex) {
     theIndex = ParsePS(aBuffer, tmpIndex+6);
 
     // We get here only if we've read <!DOCTYPE HTML PUBLIC
     // (not case sensitive) possibly with comments within.
 
     // Now find the beginning and end of the public identifier
@@ -563,17 +563,17 @@ ParseDocTypeDecl(const nsString &aBuffer
     }
 
     // Since a public ID is a minimum literal, we must trim
     // and collapse whitespace
     aPublicID = Substring(aBuffer, PublicIDStart, PublicIDEnd - PublicIDStart);
     aPublicID.CompressWhitespace(PR_TRUE, PR_TRUE);
     *aResultFlags |= PARSE_DTD_HAVE_PUBLIC_ID;
   } else {
-    tmpIndex=aBuffer.Find("SYSTEM", PR_TRUE, theIndex, 1);
+    tmpIndex=aBuffer.Find("SYSTEM", PR_TRUE, theIndex, 0);
     if (kNotFound != tmpIndex) {
       // DOCTYPES with system ID but no Public ID
       *aResultFlags |= PARSE_DTD_HAVE_SYSTEM_ID;
 
       theIndex = ParsePS(aBuffer, tmpIndex+6);
       PRUnichar next = aBuffer.CharAt(theIndex);
       if (next != PRUnichar('\"') && next != PRUnichar('\''))
         return PR_FALSE;