From 3bbedd87094bffb03aa3a23b1694ecf142f0013f Mon Sep 17 00:00:00 2001 From: "harishd%netscape.com" Date: Fri, 21 Apr 2000 21:22:03 +0000 Subject: [PATCH] Fix for 26583,2946, 22636 (partial),32782 33570,27136,24184,35125, 35806,36063,29456 r=rickg,waqar 34311 - Patch provided by Patrick ( Fix for MLK ). r=me. --- htmlparser/src/CNavDTD.cpp | 64 ++++++++++++----------- htmlparser/src/nsDTDUtils.cpp | 4 +- htmlparser/src/nsElementTable.cpp | 34 ++++++++++-- htmlparser/src/nsElementTable.h | 3 +- htmlparser/src/nsHTMLTokenizer.cpp | 2 +- htmlparser/src/nsHTMLTokens.cpp | 51 ++++++++++++------ htmlparser/src/nsIParser.h | 34 ++++++------ htmlparser/src/nsParser.cpp | 2 + parser/htmlparser/src/CNavDTD.cpp | 64 ++++++++++++----------- parser/htmlparser/src/nsDTDUtils.cpp | 4 +- parser/htmlparser/src/nsElementTable.cpp | 34 ++++++++++-- parser/htmlparser/src/nsElementTable.h | 3 +- parser/htmlparser/src/nsHTMLTokenizer.cpp | 2 +- parser/htmlparser/src/nsHTMLTokens.cpp | 51 ++++++++++++------ parser/htmlparser/src/nsIParser.h | 34 ++++++------ parser/htmlparser/src/nsParser.cpp | 2 + 16 files changed, 248 insertions(+), 140 deletions(-) diff --git a/htmlparser/src/CNavDTD.cpp b/htmlparser/src/CNavDTD.cpp index 04e90de92d4e..97af80fb253a 100644 --- a/htmlparser/src/CNavDTD.cpp +++ b/htmlparser/src/CNavDTD.cpp @@ -957,33 +957,37 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI } if(theChildAgrees && theChildIsContainer) { - if (!nsHTMLElement::IsResidualStyleTag(aChildTag)) { - if(theParentTag!=aChildTag) { - - //trying is blockcloser to widen the set of elements that this effects, re: bug 27865... - - if(nsHTMLElement::IsBlockCloser(theParentTag)) { - PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag); - - if((kNotFound
  • - - How do we know that the 2nd
    should close the
  • rather than nest inside the
  • ? - (Afterall, the
    is a legal child of the
  • ). - - The way you know is that there is no root between the two, so the
    binds more - tightly to the 1st
    than to the
  • . - - 2. Also, bug 6148 shows this case:
    - From this case we learned not to execute this logic if the parent is a block. - -------------------------------------------------------------------------------------*/ - - theChildAgrees=CanBeContained(aChildTag,*mBodyContext); - } //if - }//if - } + if(theParentTag!=aChildTag) { + // Double check the power structure a + // Note: The bit is currently set on and
  • . + if(gHTMLElements[theParentTag].ShouldVerifyHierarchy(aChildTag)){ + PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag); + + if((kNotFound
  • + How do we know that the 2nd
    should close the
  • rather than nest inside the
  • ? + (Afterall, the
    is a legal child of the
  • ). + + The way you know is that there is no root between the two, so the
    binds more + tightly to the 1st
    than to the
  • . + 2. Also, bug 6148 shows this case:
    + From this case we learned not to execute this logic if the parent is a block. + + 3. Fix for 26583 + Ex. foobar <-- A legal HTML + In the above example clicking on "foo" or "bar" should link to + foo.html or bar.html respectively. That is, the inner should be informed + about the presence of an open above ..so that the inner can close out + the outer . The following code does it for us. + + 4. Fix for 27865 [ similer to 22596 ]. Ex:
  • one
  • two + -------------------------------------------------------------------------------------*/ + + theChildAgrees=CanBeContained(aChildTag,*mBodyContext); + } //if + }//if } //if } //if } //if parentcontains @@ -1549,9 +1553,9 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) { //This is special NAV-QUIRKS code that allows users //to use
    , even though that isn't a legitimate tag. if(eParseMode_quirks==mParseMode) { - CStartToken theToken(theChildTag); //leave this on the stack; no recycling necessary. - theToken.mUseCount=1; - result=HandleStartToken(&theToken); + // Use recycler and pass the token thro' HandleToken() to fix bugs like 32782. + CHTMLToken* theToken = (CHTMLToken*)mTokenRecycler->CreateTokenOfType(eToken_start,theChildTag); + result=HandleToken(theToken,mParser); } } break; diff --git a/htmlparser/src/nsDTDUtils.cpp b/htmlparser/src/nsDTDUtils.cpp index ef762c6854f8..2a3867bc9cbe 100644 --- a/htmlparser/src/nsDTDUtils.cpp +++ b/htmlparser/src/nsDTDUtils.cpp @@ -1180,7 +1180,7 @@ void CObserverService::RegisterObservers(const nsString& aTopic) { nsServiceManager::ReleaseService(NS_OBSERVERSERVICE_PROGID, theObserverService); if(result == NS_OK) { - nsIElementObserver *theElementObserver = nsnull; + nsCOMPtr theElementObserver; nsISupports *inst = nsnull; nsObserverTopic *theTopic=0; @@ -1188,7 +1188,7 @@ void CObserverService::RegisterObservers(const nsString& aTopic) { for (theEnum->First(); theEnum->IsDone() != NS_OK; theEnum->Next()) { result = theEnum->CurrentItem(&inst); if (NS_SUCCEEDED(result)) { - result = inst->QueryInterface(NS_GET_IID(nsIElementObserver), (void**)&theElementObserver); + theElementObserver = do_QueryInterface(inst, &result); NS_RELEASE(inst); } if (result == NS_OK) { diff --git a/htmlparser/src/nsElementTable.cpp b/htmlparser/src/nsElementTable.cpp index 7c40ee0712b8..5f3211ac9ef5 100644 --- a/htmlparser/src/nsElementTable.cpp +++ b/htmlparser/src/nsElementTable.cpp @@ -219,7 +219,7 @@ void InitializeElementTable(void) { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0,0, /*parent,incl,exclgroups*/ kSpecial, kInlineEntity, kNone, - /*special props, prop-range*/ 0,kDefaultPropRange, + /*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown); Initialize( @@ -760,7 +760,7 @@ void InitializeElementTable(void) { /*rootnodes,endrootnodes*/ &gLIRootTags,&gLIRootTags, /*autoclose starttags and endtags*/ &gLIAutoClose,0,0,0, /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kSelf, //changed this from blockentity to block during RS cleanup - /*special props, prop-range*/ kNoPropagate, kDefaultPropRange, + /*special props, prop-range*/ kNoPropagate|kVerifyHierarchy, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gLIKids,eHTMLTag_unknown); Initialize( @@ -891,11 +891,11 @@ void InitializeElementTable(void) { Initialize( /*tag*/ eHTMLTag_option, - /*requiredAncestor*/ eHTMLTag_unknown,eHTMLTag_unknown, + /*requiredAncestor*/ eHTMLTag_select,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents, /*autoclose starttags and endtags*/ 0,0,0,0, /*parent,incl,exclgroups*/ kNone, kPCDATA, kFlowEntity, - /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, + /*special props, prop-range*/ kNoStyleLeaksIn|kNoPropagate, kDefaultPropRange, /*special parents,kids,skip*/ &gOptgroupParents,&gContainsText,eHTMLTag_unknown); Initialize( @@ -1678,6 +1678,32 @@ PRBool nsHTMLElement::SectionContains(eHTMLTags aChild,PRBool allowDepthSearch) return result; } +/** + * This method should be called to determine if the a tags + * hierarchy needs to be validated. + * + * @update harishd 04/19/00 + * @param + * @return + */ + +PRBool nsHTMLElement::ShouldVerifyHierarchy(eHTMLTags aChildTag) { + PRBool result=PR_FALSE; + + // If the tag cannot contain itself then we need to make sure that + // anywhere in the hierarchy we don't nest accidently. + // Ex:

  • . Inner LI has the potential of getting nested + // inside outer LI.If the tag can contain self, Ex: , + // ( B can contain self )then ask the child () if it requires a containment check. + if(aChildTag!=eHTMLTag_userdefined) { + if(CanContainSelf()) { + result=gHTMLElements[aChildTag].HasSpecialProperty(kVerifyHierarchy); + } + else result=PR_TRUE; + } + return result; +} + /** * * @update gess12/13/98 diff --git a/htmlparser/src/nsElementTable.h b/htmlparser/src/nsElementTable.h index b659f212971a..e1944f201719 100644 --- a/htmlparser/src/nsElementTable.h +++ b/htmlparser/src/nsElementTable.h @@ -173,6 +173,7 @@ struct nsHTMLElement { PRBool IsSpecialParent(eHTMLTags aTag) const; PRBool IsExcludableParent(eHTMLTags aParent) const; PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch); + PRBool ShouldVerifyHierarchy(eHTMLTags achildTag); static PRBool CanContain(eHTMLTags aParent,eHTMLTags aChild); static PRBool IsContainer(eHTMLTags aTag) ; @@ -224,6 +225,6 @@ static const int kSaveMisplaced = 0x0200; //If set, then children this tag ca static const int kNonContainer = 0x0400; //If set, then this tag is not a container. static const int kHandleStrayTag = 0x0800; //If set, we automatically open a start tag static const int kRequiresBody = 0x1000; //If set, then in case of no BODY one will be opened up immediately. - +static const int kVerifyHierarchy = 0x2000; //If set, check to see if the tag is a child or a sibling.. #endif diff --git a/htmlparser/src/nsHTMLTokenizer.cpp b/htmlparser/src/nsHTMLTokenizer.cpp index e4b4c295a691..71fb0bfed93a 100644 --- a/htmlparser/src/nsHTMLTokenizer.cpp +++ b/htmlparser/src/nsHTMLTokenizer.cpp @@ -551,7 +551,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan nsAutoString endTag(nsHTMLTags::GetStringValue(theTag)); endTag.InsertWithConversion("CreateTokenOfType(eToken_text,theTag); - result=((CTextToken*)textToken)->ConsumeUntil(0,PR_FALSE,aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text... + result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text... //endTag.Append(">"); CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag,endTag); AddToken(textToken,result,&mTokenDeque,theRecycler); diff --git a/htmlparser/src/nsHTMLTokens.cpp b/htmlparser/src/nsHTMLTokens.cpp index 157d9d25df1d..a0ede590ff16 100644 --- a/htmlparser/src/nsHTMLTokens.cpp +++ b/htmlparser/src/nsHTMLTokens.cpp @@ -614,20 +614,22 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann } //theTermStrPos=theBuffer.Find(aTerminalString,PR_TRUE,theCurrOffset); if(theTermStrPos>kNotFound) { - if(aMode!=eParseMode_noquirks && !theLastIteration && !aIgnoreComments) { - theCurrOffset=theBuffer.Find(" between ",PR_TRUE,theTermStrPos,theTermStrPos-theStartCommentPos); - if(theCurrOffset==kNotFound) { - // If you're here it means that we have a bogus terminal string. - theAltTermStrPos=(theAltTermStrPos>-1)? theAltTermStrPos:theTermStrPos; // This could be helpful in case we hit the rock bottom. - theCurrOffset=theTermStrPos+termStrLen; // We did not find '-->' so keep searching for terminal string. - continue; - } + if(aMode!=eParseMode_noquirks && !theLastIteration) { + if(!aIgnoreComments) { + theCurrOffset=theBuffer.Find(" between ",PR_TRUE,theTermStrPos,theTermStrPos-theStartCommentPos); + if(theCurrOffset==kNotFound) { + // If you're here it means that we have a bogus terminal string. + theAltTermStrPos=(theAltTermStrPos>-1)? theAltTermStrPos:theTermStrPos; // This could be helpful in case we hit the rock bottom. + theCurrOffset=theTermStrPos+termStrLen; // We did not find '-->' so keep searching for terminal string. + continue; + } + } } PRInt32 thePos=theBuffer.FindChar(kGreaterThan,PR_TRUE,theTermStrPos,20); @@ -1248,6 +1250,8 @@ void CAttributeToken::AppendSource(nsString& anOutputString){ */ nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScanner){ nsresult result=NS_OK; + PRInt32 theOffset=aScanner.GetOffset(); + switch(aChar) { case kQuote: result=aScanner.ReadUntil(aString,kQuote,PR_TRUE); @@ -1262,9 +1266,21 @@ nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScann default: break; } + + // Ref: Bug 35806 + // A back up measure when disaster strikes... + // Ex WillBuildModel(*pc,nsnull); // Fixing UMR - Bug 33570 + pc->mMultipart=!aLastCall; //by default if (pc->mPrevContext) { pc->mMultipart |= pc->mPrevContext->mMultipart; //if available diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp index 04e90de92d4e..97af80fb253a 100644 --- a/parser/htmlparser/src/CNavDTD.cpp +++ b/parser/htmlparser/src/CNavDTD.cpp @@ -957,33 +957,37 @@ nsresult CNavDTD::HandleDefaultStartToken(CToken* aToken,eHTMLTags aChildTag,nsI } if(theChildAgrees && theChildIsContainer) { - if (!nsHTMLElement::IsResidualStyleTag(aChildTag)) { - if(theParentTag!=aChildTag) { - - //trying is blockcloser to widen the set of elements that this effects, re: bug 27865... - - if(nsHTMLElement::IsBlockCloser(theParentTag)) { - PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag); - - if((kNotFound
  • - - How do we know that the 2nd
    should close the
  • rather than nest inside the
  • ? - (Afterall, the
    is a legal child of the
  • ). - - The way you know is that there is no root between the two, so the
    binds more - tightly to the 1st
    than to the
  • . - - 2. Also, bug 6148 shows this case:
    - From this case we learned not to execute this logic if the parent is a block. - -------------------------------------------------------------------------------------*/ - - theChildAgrees=CanBeContained(aChildTag,*mBodyContext); - } //if - }//if - } + if(theParentTag!=aChildTag) { + // Double check the power structure a + // Note: The bit is currently set on and
  • . + if(gHTMLElements[theParentTag].ShouldVerifyHierarchy(aChildTag)){ + PRInt32 theChildIndex=GetIndexOfChildOrSynonym(*mBodyContext,aChildTag); + + if((kNotFound
  • + How do we know that the 2nd
    should close the
  • rather than nest inside the
  • ? + (Afterall, the
    is a legal child of the
  • ). + + The way you know is that there is no root between the two, so the
    binds more + tightly to the 1st
    than to the
  • . + 2. Also, bug 6148 shows this case:
    + From this case we learned not to execute this logic if the parent is a block. + + 3. Fix for 26583 + Ex. foobar <-- A legal HTML + In the above example clicking on "foo" or "bar" should link to + foo.html or bar.html respectively. That is, the inner should be informed + about the presence of an open above ..so that the inner can close out + the outer . The following code does it for us. + + 4. Fix for 27865 [ similer to 22596 ]. Ex:
  • one
  • two + -------------------------------------------------------------------------------------*/ + + theChildAgrees=CanBeContained(aChildTag,*mBodyContext); + } //if + }//if } //if } //if } //if parentcontains @@ -1549,9 +1553,9 @@ nsresult CNavDTD::HandleEndToken(CToken* aToken) { //This is special NAV-QUIRKS code that allows users //to use
    , even though that isn't a legitimate tag. if(eParseMode_quirks==mParseMode) { - CStartToken theToken(theChildTag); //leave this on the stack; no recycling necessary. - theToken.mUseCount=1; - result=HandleStartToken(&theToken); + // Use recycler and pass the token thro' HandleToken() to fix bugs like 32782. + CHTMLToken* theToken = (CHTMLToken*)mTokenRecycler->CreateTokenOfType(eToken_start,theChildTag); + result=HandleToken(theToken,mParser); } } break; diff --git a/parser/htmlparser/src/nsDTDUtils.cpp b/parser/htmlparser/src/nsDTDUtils.cpp index ef762c6854f8..2a3867bc9cbe 100644 --- a/parser/htmlparser/src/nsDTDUtils.cpp +++ b/parser/htmlparser/src/nsDTDUtils.cpp @@ -1180,7 +1180,7 @@ void CObserverService::RegisterObservers(const nsString& aTopic) { nsServiceManager::ReleaseService(NS_OBSERVERSERVICE_PROGID, theObserverService); if(result == NS_OK) { - nsIElementObserver *theElementObserver = nsnull; + nsCOMPtr theElementObserver; nsISupports *inst = nsnull; nsObserverTopic *theTopic=0; @@ -1188,7 +1188,7 @@ void CObserverService::RegisterObservers(const nsString& aTopic) { for (theEnum->First(); theEnum->IsDone() != NS_OK; theEnum->Next()) { result = theEnum->CurrentItem(&inst); if (NS_SUCCEEDED(result)) { - result = inst->QueryInterface(NS_GET_IID(nsIElementObserver), (void**)&theElementObserver); + theElementObserver = do_QueryInterface(inst, &result); NS_RELEASE(inst); } if (result == NS_OK) { diff --git a/parser/htmlparser/src/nsElementTable.cpp b/parser/htmlparser/src/nsElementTable.cpp index 7c40ee0712b8..5f3211ac9ef5 100644 --- a/parser/htmlparser/src/nsElementTable.cpp +++ b/parser/htmlparser/src/nsElementTable.cpp @@ -219,7 +219,7 @@ void InitializeElementTable(void) { /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags, /*autoclose starttags and endtags*/ 0,0,0,0, /*parent,incl,exclgroups*/ kSpecial, kInlineEntity, kNone, - /*special props, prop-range*/ 0,kDefaultPropRange, + /*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange, /*special parents,kids,skip*/ 0,0,eHTMLTag_unknown); Initialize( @@ -760,7 +760,7 @@ void InitializeElementTable(void) { /*rootnodes,endrootnodes*/ &gLIRootTags,&gLIRootTags, /*autoclose starttags and endtags*/ &gLIAutoClose,0,0,0, /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kSelf, //changed this from blockentity to block during RS cleanup - /*special props, prop-range*/ kNoPropagate, kDefaultPropRange, + /*special props, prop-range*/ kNoPropagate|kVerifyHierarchy, kDefaultPropRange, /*special parents,kids,skip*/ 0,&gLIKids,eHTMLTag_unknown); Initialize( @@ -891,11 +891,11 @@ void InitializeElementTable(void) { Initialize( /*tag*/ eHTMLTag_option, - /*requiredAncestor*/ eHTMLTag_unknown,eHTMLTag_unknown, + /*requiredAncestor*/ eHTMLTag_select,eHTMLTag_unknown, /*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents, /*autoclose starttags and endtags*/ 0,0,0,0, /*parent,incl,exclgroups*/ kNone, kPCDATA, kFlowEntity, - /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange, + /*special props, prop-range*/ kNoStyleLeaksIn|kNoPropagate, kDefaultPropRange, /*special parents,kids,skip*/ &gOptgroupParents,&gContainsText,eHTMLTag_unknown); Initialize( @@ -1678,6 +1678,32 @@ PRBool nsHTMLElement::SectionContains(eHTMLTags aChild,PRBool allowDepthSearch) return result; } +/** + * This method should be called to determine if the a tags + * hierarchy needs to be validated. + * + * @update harishd 04/19/00 + * @param + * @return + */ + +PRBool nsHTMLElement::ShouldVerifyHierarchy(eHTMLTags aChildTag) { + PRBool result=PR_FALSE; + + // If the tag cannot contain itself then we need to make sure that + // anywhere in the hierarchy we don't nest accidently. + // Ex:

  • . Inner LI has the potential of getting nested + // inside outer LI.If the tag can contain self, Ex: , + // ( B can contain self )then ask the child () if it requires a containment check. + if(aChildTag!=eHTMLTag_userdefined) { + if(CanContainSelf()) { + result=gHTMLElements[aChildTag].HasSpecialProperty(kVerifyHierarchy); + } + else result=PR_TRUE; + } + return result; +} + /** * * @update gess12/13/98 diff --git a/parser/htmlparser/src/nsElementTable.h b/parser/htmlparser/src/nsElementTable.h index b659f212971a..e1944f201719 100644 --- a/parser/htmlparser/src/nsElementTable.h +++ b/parser/htmlparser/src/nsElementTable.h @@ -173,6 +173,7 @@ struct nsHTMLElement { PRBool IsSpecialParent(eHTMLTags aTag) const; PRBool IsExcludableParent(eHTMLTags aParent) const; PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch); + PRBool ShouldVerifyHierarchy(eHTMLTags achildTag); static PRBool CanContain(eHTMLTags aParent,eHTMLTags aChild); static PRBool IsContainer(eHTMLTags aTag) ; @@ -224,6 +225,6 @@ static const int kSaveMisplaced = 0x0200; //If set, then children this tag ca static const int kNonContainer = 0x0400; //If set, then this tag is not a container. static const int kHandleStrayTag = 0x0800; //If set, we automatically open a start tag static const int kRequiresBody = 0x1000; //If set, then in case of no BODY one will be opened up immediately. - +static const int kVerifyHierarchy = 0x2000; //If set, check to see if the tag is a child or a sibling.. #endif diff --git a/parser/htmlparser/src/nsHTMLTokenizer.cpp b/parser/htmlparser/src/nsHTMLTokenizer.cpp index e4b4c295a691..71fb0bfed93a 100644 --- a/parser/htmlparser/src/nsHTMLTokenizer.cpp +++ b/parser/htmlparser/src/nsHTMLTokenizer.cpp @@ -551,7 +551,7 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan nsAutoString endTag(nsHTMLTags::GetStringValue(theTag)); endTag.InsertWithConversion("CreateTokenOfType(eToken_text,theTag); - result=((CTextToken*)textToken)->ConsumeUntil(0,PR_FALSE,aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text... + result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(theTag!=eHTMLTag_script),aScanner,endTag,mParseMode,aFlushTokens); //tell new token to finish consuming text... //endTag.Append(">"); CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag,endTag); AddToken(textToken,result,&mTokenDeque,theRecycler); diff --git a/parser/htmlparser/src/nsHTMLTokens.cpp b/parser/htmlparser/src/nsHTMLTokens.cpp index 157d9d25df1d..a0ede590ff16 100644 --- a/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/parser/htmlparser/src/nsHTMLTokens.cpp @@ -614,20 +614,22 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann } //theTermStrPos=theBuffer.Find(aTerminalString,PR_TRUE,theCurrOffset); if(theTermStrPos>kNotFound) { - if(aMode!=eParseMode_noquirks && !theLastIteration && !aIgnoreComments) { - theCurrOffset=theBuffer.Find(" between ",PR_TRUE,theTermStrPos,theTermStrPos-theStartCommentPos); - if(theCurrOffset==kNotFound) { - // If you're here it means that we have a bogus terminal string. - theAltTermStrPos=(theAltTermStrPos>-1)? theAltTermStrPos:theTermStrPos; // This could be helpful in case we hit the rock bottom. - theCurrOffset=theTermStrPos+termStrLen; // We did not find '-->' so keep searching for terminal string. - continue; - } + if(aMode!=eParseMode_noquirks && !theLastIteration) { + if(!aIgnoreComments) { + theCurrOffset=theBuffer.Find(" between ",PR_TRUE,theTermStrPos,theTermStrPos-theStartCommentPos); + if(theCurrOffset==kNotFound) { + // If you're here it means that we have a bogus terminal string. + theAltTermStrPos=(theAltTermStrPos>-1)? theAltTermStrPos:theTermStrPos; // This could be helpful in case we hit the rock bottom. + theCurrOffset=theTermStrPos+termStrLen; // We did not find '-->' so keep searching for terminal string. + continue; + } + } } PRInt32 thePos=theBuffer.FindChar(kGreaterThan,PR_TRUE,theTermStrPos,20); @@ -1248,6 +1250,8 @@ void CAttributeToken::AppendSource(nsString& anOutputString){ */ nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScanner){ nsresult result=NS_OK; + PRInt32 theOffset=aScanner.GetOffset(); + switch(aChar) { case kQuote: result=aScanner.ReadUntil(aString,kQuote,PR_TRUE); @@ -1262,9 +1266,21 @@ nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScann default: break; } + + // Ref: Bug 35806 + // A back up measure when disaster strikes... + // Ex
  • WillBuildModel(*pc,nsnull); // Fixing UMR - Bug 33570 + pc->mMultipart=!aLastCall; //by default if (pc->mPrevContext) { pc->mMultipart |= pc->mPrevContext->mMultipart; //if available