mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Fix CDATA tokenization in view-source mode end the CDATA section on "]>", not
']' (as it needs to do for normal parsing mode). Bug 209485, r=harishd, sr=jst
This commit is contained in:
parent
e355b2283f
commit
a60cd171ee
@ -781,7 +781,7 @@ nsresult CCDATASectionToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt3
|
||||
} //switch
|
||||
} //if
|
||||
}
|
||||
else if (']'==aChar) {
|
||||
else if (kRightSquareBracket == aChar) {
|
||||
result=aScanner.GetChar(aChar); //strip off the ]
|
||||
mTextValue.Append(aChar);
|
||||
result=aScanner.Peek(aChar); //then see what's next.
|
||||
@ -789,9 +789,24 @@ nsresult CCDATASectionToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt3
|
||||
result=aScanner.GetChar(aChar); //strip off the second ]
|
||||
mTextValue.Append(aChar);
|
||||
}
|
||||
nsAutoString dummy; // skip any bad data
|
||||
result=aScanner.ReadUntil(dummy,kGreaterThan,PR_FALSE);
|
||||
if (NS_OK==result) {
|
||||
// The goal here is to not lose data from the page when encountering
|
||||
// markup like: <![endif]-->. This means that in normal parsing, we
|
||||
// allow ']' to end the marked section and just drop everything between
|
||||
// it an the '>'. In view-source mode, we cannot drop things on the
|
||||
// floor like that. In fact, to make view-source of XML with script in
|
||||
// CDATA sections at all bearable, we need to somewhat enforce the ']>'
|
||||
// terminator for marked sections. So make the tokenization somewhat
|
||||
// different when in view-source _and_ dealing with a CDATA section.
|
||||
PRBool inCDATA = (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) &&
|
||||
StringBeginsWith(mTextValue, NS_LITERAL_STRING("[CDATA["));
|
||||
if (inCDATA) {
|
||||
result = aScanner.Peek(aChar);
|
||||
} else {
|
||||
nsAutoString dummy; // skip any bad data
|
||||
result=aScanner.ReadUntil(dummy,kGreaterThan,PR_FALSE);
|
||||
}
|
||||
if (NS_OK==result &&
|
||||
(!inCDATA || kGreaterThan == aChar)) {
|
||||
result=aScanner.GetChar(aChar); //strip off the >
|
||||
done=PR_TRUE;
|
||||
}
|
||||
|
@ -781,7 +781,7 @@ nsresult CCDATASectionToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt3
|
||||
} //switch
|
||||
} //if
|
||||
}
|
||||
else if (']'==aChar) {
|
||||
else if (kRightSquareBracket == aChar) {
|
||||
result=aScanner.GetChar(aChar); //strip off the ]
|
||||
mTextValue.Append(aChar);
|
||||
result=aScanner.Peek(aChar); //then see what's next.
|
||||
@ -789,9 +789,24 @@ nsresult CCDATASectionToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt3
|
||||
result=aScanner.GetChar(aChar); //strip off the second ]
|
||||
mTextValue.Append(aChar);
|
||||
}
|
||||
nsAutoString dummy; // skip any bad data
|
||||
result=aScanner.ReadUntil(dummy,kGreaterThan,PR_FALSE);
|
||||
if (NS_OK==result) {
|
||||
// The goal here is to not lose data from the page when encountering
|
||||
// markup like: <![endif]-->. This means that in normal parsing, we
|
||||
// allow ']' to end the marked section and just drop everything between
|
||||
// it an the '>'. In view-source mode, we cannot drop things on the
|
||||
// floor like that. In fact, to make view-source of XML with script in
|
||||
// CDATA sections at all bearable, we need to somewhat enforce the ']>'
|
||||
// terminator for marked sections. So make the tokenization somewhat
|
||||
// different when in view-source _and_ dealing with a CDATA section.
|
||||
PRBool inCDATA = (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) &&
|
||||
StringBeginsWith(mTextValue, NS_LITERAL_STRING("[CDATA["));
|
||||
if (inCDATA) {
|
||||
result = aScanner.Peek(aChar);
|
||||
} else {
|
||||
nsAutoString dummy; // skip any bad data
|
||||
result=aScanner.ReadUntil(dummy,kGreaterThan,PR_FALSE);
|
||||
}
|
||||
if (NS_OK==result &&
|
||||
(!inCDATA || kGreaterThan == aChar)) {
|
||||
result=aScanner.GetChar(aChar); //strip off the >
|
||||
done=PR_TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user