From 67ae246c6c139aee6e3bc9487d5604b7221f51bb Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Tue, 23 Mar 1999 00:23:51 +0000 Subject: [PATCH] fixed badly formed entity bug git-svn-id: svn://10.0.0.236/trunk@24748 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/nsHTMLTokenizer.cpp | 17 ++++++++++++++++- .../parser/htmlparser/src/nsHTMLTokenizer.cpp | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp index 7381816f12e..4279baf16f8 100644 --- a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp @@ -28,6 +28,7 @@ #include "nsScanner.h" #include "nsDTDUtils.h" #include "nsElementTable.h" +#include "nsHTMLEntities.h" /************************************************************************ And now for the main class -- nsHTMLTokenizer... @@ -539,7 +540,21 @@ nsresult nsHTMLTokenizer::ConsumeEntity(PRUnichar aChar,CToken*& aToken,nsScanne aScanner.PutBack(theChar); return ConsumeText(temp,aToken,aScanner); }//if - AddToken(aToken,result,mTokenDeque); + if(aToken){ + char cbuf[30]; + nsString& theStr=aToken->GetStringValueXXX(); + theStr.ToCString(cbuf, sizeof(cbuf)-1); + if(-1==NS_EntityToUnicode(cbuf)){ + //if you're here we have a bogus entity. + //convert it into a text token. + nsAutoString temp("&"); + temp.Append(theStr); + CToken* theToken=theRecycler->CreateTokenOfType(eToken_text,eHTMLTag_text,temp); + theRecycler->RecycleToken(aToken); + aToken=theToken; + } + AddToken(aToken,result,mTokenDeque); + } }//if return result; } diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp index 7381816f12e..4279baf16f8 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp @@ -28,6 +28,7 @@ #include "nsScanner.h" #include "nsDTDUtils.h" #include "nsElementTable.h" +#include "nsHTMLEntities.h" /************************************************************************ And now for the main class -- nsHTMLTokenizer... @@ -539,7 +540,21 @@ nsresult nsHTMLTokenizer::ConsumeEntity(PRUnichar aChar,CToken*& aToken,nsScanne aScanner.PutBack(theChar); return ConsumeText(temp,aToken,aScanner); }//if - AddToken(aToken,result,mTokenDeque); + if(aToken){ + char cbuf[30]; + nsString& theStr=aToken->GetStringValueXXX(); + theStr.ToCString(cbuf, sizeof(cbuf)-1); + if(-1==NS_EntityToUnicode(cbuf)){ + //if you're here we have a bogus entity. + //convert it into a text token. + nsAutoString temp("&"); + temp.Append(theStr); + CToken* theToken=theRecycler->CreateTokenOfType(eToken_text,eHTMLTag_text,temp); + theRecycler->RecycleToken(aToken); + aToken=theToken; + } + AddToken(aToken,result,mTokenDeque); + } }//if return result; }