mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
r=nisheeth. Fix for bug 9781 submitted by Johnny Stenbeck (jst@citec.fi). Thanks Johnny.
This commit is contained in:
parent
4a72e1465c
commit
ff14b7a0cf
@ -834,7 +834,18 @@ nsXMLContentSink::AddLeaf(const nsIParserNode& aNode)
|
||||
break;
|
||||
|
||||
case eToken_cdatasection:
|
||||
AddCDATASection(aNode);
|
||||
/*
|
||||
* If we're inside a <html:script> tag we add the data as text so that
|
||||
* the script can be processed.
|
||||
*
|
||||
* -- jst@citec.fi
|
||||
*/
|
||||
if (mInScript) {
|
||||
AddText(aNode.GetText());
|
||||
} else {
|
||||
AddCDATASection(aNode);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case eToken_entity:
|
||||
|
@ -138,6 +138,9 @@ void nsExpatTokenizer::SetupExpatCallbacks(void) {
|
||||
XML_SetExternalEntityRefHandler(mExpatParser, HandleExternalEntityRef);
|
||||
XML_SetCommentHandler(mExpatParser, HandleComment);
|
||||
XML_SetUnknownEncodingHandler(mExpatParser, HandleUnknownEncoding, NULL);
|
||||
XML_SetCdataSectionHandler(mExpatParser, HandleStartCdataSection,
|
||||
HandleEndCdataSection);
|
||||
|
||||
XML_SetDoctypeDeclHandler(mExpatParser, HandleStartDoctypeDecl, HandleEndDoctypeDecl);
|
||||
}
|
||||
}
|
||||
@ -399,31 +402,13 @@ void nsExpatTokenizer::HandleEndElement(void *userData, const XML_Char *name) {
|
||||
|
||||
void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, int len) {
|
||||
CCDATASectionToken* currentCDataToken = (CCDATASectionToken*) userData;
|
||||
PRBool StartOfCDataSection = (!currentCDataToken && len == 0);
|
||||
PRBool EndOfCDataSection = (currentCDataToken && len == 0);
|
||||
|
||||
// Either create a new token (if not currently within a CDATA section) or add the
|
||||
// current string from expat to the current CDATA token.
|
||||
|
||||
if (StartOfCDataSection) {
|
||||
// Set up state so that we know that we are within a CDATA section.
|
||||
currentCDataToken = (CCDATASectionToken*) gTokenRecycler->CreateTokenOfType(eToken_cdatasection,eHTMLTag_unknown);
|
||||
XML_SetUserData(gExpatParser, (void *) currentCDataToken);
|
||||
}
|
||||
else if (EndOfCDataSection) {
|
||||
// We've reached the end of the current CDATA section. Push the current CDATA token
|
||||
// onto the token queue and reset state to being outside a CDATA section.
|
||||
CToken* tempCDATAToken = (CToken*) currentCDataToken;
|
||||
AddToken(tempCDATAToken,NS_OK,*gTokenDeque,gTokenRecycler);
|
||||
currentCDataToken = 0;
|
||||
XML_SetUserData(gExpatParser, 0);
|
||||
}
|
||||
else if (currentCDataToken) {
|
||||
// While there exists a current CDATA token, keep appending all strings from expat into it.
|
||||
if (currentCDataToken) {
|
||||
// While there exists a current CDATA token, keep appending all strings
|
||||
// from expat into it.
|
||||
nsString& theString = currentCDataToken->GetStringValueXXX();
|
||||
theString.Append((PRUnichar *) s,len);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
CToken* newToken = 0;
|
||||
|
||||
switch(s[0]){
|
||||
@ -462,6 +447,23 @@ void nsExpatTokenizer::HandleComment(void *userData, const XML_Char *name) {
|
||||
}
|
||||
}
|
||||
|
||||
void nsExpatTokenizer::HandleStartCdataSection(void *userData) {
|
||||
CToken* cdataToken = gTokenRecycler->CreateTokenOfType(eToken_cdatasection,
|
||||
eHTMLTag_unknown);
|
||||
|
||||
XML_SetUserData(gExpatParser, (void *) cdataToken);
|
||||
}
|
||||
|
||||
void nsExpatTokenizer::HandleEndCdataSection(void *userData) {
|
||||
CToken* currentCDataToken = (CToken*) userData;
|
||||
|
||||
// We've reached the end of the current CDATA section. Push the current
|
||||
// CDATA token onto the token queue
|
||||
AddToken(currentCDataToken,NS_OK,*gTokenDeque,gTokenRecycler);
|
||||
|
||||
XML_SetUserData(gExpatParser, nsnull);
|
||||
}
|
||||
|
||||
void nsExpatTokenizer::HandleProcessingInstruction(void *userData, const XML_Char *target, const XML_Char *data){
|
||||
CToken* theToken=gTokenRecycler->CreateTokenOfType(eToken_instruction,eHTMLTag_unknown);
|
||||
if(theToken) {
|
||||
|
@ -102,6 +102,8 @@ protected:
|
||||
const XML_Char *target,
|
||||
const XML_Char *data);
|
||||
static void HandleDefault(void *userData, const XML_Char *s, int len);
|
||||
static void HandleStartCdataSection(void *userData);
|
||||
static void HandleEndCdataSection(void *userData);
|
||||
static void HandleUnparsedEntityDecl(void *userData,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
|
@ -834,7 +834,18 @@ nsXMLContentSink::AddLeaf(const nsIParserNode& aNode)
|
||||
break;
|
||||
|
||||
case eToken_cdatasection:
|
||||
AddCDATASection(aNode);
|
||||
/*
|
||||
* If we're inside a <html:script> tag we add the data as text so that
|
||||
* the script can be processed.
|
||||
*
|
||||
* -- jst@citec.fi
|
||||
*/
|
||||
if (mInScript) {
|
||||
AddText(aNode.GetText());
|
||||
} else {
|
||||
AddCDATASection(aNode);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case eToken_entity:
|
||||
|
@ -138,6 +138,9 @@ void nsExpatTokenizer::SetupExpatCallbacks(void) {
|
||||
XML_SetExternalEntityRefHandler(mExpatParser, HandleExternalEntityRef);
|
||||
XML_SetCommentHandler(mExpatParser, HandleComment);
|
||||
XML_SetUnknownEncodingHandler(mExpatParser, HandleUnknownEncoding, NULL);
|
||||
XML_SetCdataSectionHandler(mExpatParser, HandleStartCdataSection,
|
||||
HandleEndCdataSection);
|
||||
|
||||
XML_SetDoctypeDeclHandler(mExpatParser, HandleStartDoctypeDecl, HandleEndDoctypeDecl);
|
||||
}
|
||||
}
|
||||
@ -399,31 +402,13 @@ void nsExpatTokenizer::HandleEndElement(void *userData, const XML_Char *name) {
|
||||
|
||||
void nsExpatTokenizer::HandleCharacterData(void *userData, const XML_Char *s, int len) {
|
||||
CCDATASectionToken* currentCDataToken = (CCDATASectionToken*) userData;
|
||||
PRBool StartOfCDataSection = (!currentCDataToken && len == 0);
|
||||
PRBool EndOfCDataSection = (currentCDataToken && len == 0);
|
||||
|
||||
// Either create a new token (if not currently within a CDATA section) or add the
|
||||
// current string from expat to the current CDATA token.
|
||||
|
||||
if (StartOfCDataSection) {
|
||||
// Set up state so that we know that we are within a CDATA section.
|
||||
currentCDataToken = (CCDATASectionToken*) gTokenRecycler->CreateTokenOfType(eToken_cdatasection,eHTMLTag_unknown);
|
||||
XML_SetUserData(gExpatParser, (void *) currentCDataToken);
|
||||
}
|
||||
else if (EndOfCDataSection) {
|
||||
// We've reached the end of the current CDATA section. Push the current CDATA token
|
||||
// onto the token queue and reset state to being outside a CDATA section.
|
||||
CToken* tempCDATAToken = (CToken*) currentCDataToken;
|
||||
AddToken(tempCDATAToken,NS_OK,*gTokenDeque,gTokenRecycler);
|
||||
currentCDataToken = 0;
|
||||
XML_SetUserData(gExpatParser, 0);
|
||||
}
|
||||
else if (currentCDataToken) {
|
||||
// While there exists a current CDATA token, keep appending all strings from expat into it.
|
||||
if (currentCDataToken) {
|
||||
// While there exists a current CDATA token, keep appending all strings
|
||||
// from expat into it.
|
||||
nsString& theString = currentCDataToken->GetStringValueXXX();
|
||||
theString.Append((PRUnichar *) s,len);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
CToken* newToken = 0;
|
||||
|
||||
switch(s[0]){
|
||||
@ -462,6 +447,23 @@ void nsExpatTokenizer::HandleComment(void *userData, const XML_Char *name) {
|
||||
}
|
||||
}
|
||||
|
||||
void nsExpatTokenizer::HandleStartCdataSection(void *userData) {
|
||||
CToken* cdataToken = gTokenRecycler->CreateTokenOfType(eToken_cdatasection,
|
||||
eHTMLTag_unknown);
|
||||
|
||||
XML_SetUserData(gExpatParser, (void *) cdataToken);
|
||||
}
|
||||
|
||||
void nsExpatTokenizer::HandleEndCdataSection(void *userData) {
|
||||
CToken* currentCDataToken = (CToken*) userData;
|
||||
|
||||
// We've reached the end of the current CDATA section. Push the current
|
||||
// CDATA token onto the token queue
|
||||
AddToken(currentCDataToken,NS_OK,*gTokenDeque,gTokenRecycler);
|
||||
|
||||
XML_SetUserData(gExpatParser, nsnull);
|
||||
}
|
||||
|
||||
void nsExpatTokenizer::HandleProcessingInstruction(void *userData, const XML_Char *target, const XML_Char *data){
|
||||
CToken* theToken=gTokenRecycler->CreateTokenOfType(eToken_instruction,eHTMLTag_unknown);
|
||||
if(theToken) {
|
||||
|
@ -102,6 +102,8 @@ protected:
|
||||
const XML_Char *target,
|
||||
const XML_Char *data);
|
||||
static void HandleDefault(void *userData, const XML_Char *s, int len);
|
||||
static void HandleStartCdataSection(void *userData);
|
||||
static void HandleEndCdataSection(void *userData);
|
||||
static void HandleUnparsedEntityDecl(void *userData,
|
||||
const XML_Char *entityName,
|
||||
const XML_Char *base,
|
||||
|
Loading…
Reference in New Issue
Block a user