Bug 339350. innerHTML removes trailing bracket symbols. r=mrbkap, sr=sicking, a=dveditz

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@216160 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sayrer%gmail.com
2006-11-30 17:53:11 +00:00
parent aee74024da
commit bb422a4f60

View File

@@ -1920,28 +1920,44 @@ nsParser::ParseFragment(const nsAString& aSourceBuffer,
}
fragSink->WillBuildContent();
// Now, parse the actual content. Note that this is the last call for HTML
// content, but for XML, we will want to build and parse the end tags.
result = Parse(aSourceBuffer, (void*)&theContext, aMimeType,
PR_FALSE, !aXMLMode, aMode);
fragSink->DidBuildContent();
if (aXMLMode && NS_SUCCEEDED(result)) {
nsAutoString endContext;
for (theIndex = 0; theIndex < theCount; theIndex++) {
endContext.AppendLiteral("</");
nsAutoString thisTag( (PRUnichar*)aTagStack.ElementAt(theIndex) );
PRInt32 endOfTag = thisTag.FindChar(PRUnichar(' ')); // was there an xmlns=?
if (endOfTag == -1)
endContext.Append( thisTag );
else
endContext.Append( Substring(thisTag,0,endOfTag) );
endContext.AppendLiteral(">");
}
result = Parse(endContext, (void*)&theContext, aMimeType,
// Now, parse the actual content. Note that this is the last call
// for HTML content, but for XML, we will want to build and parse
// the end tags. However, if tagStack is empty, it's the last call
// for XML as well.
if (!aXMLMode || (theCount == 0)) {
result = Parse(aSourceBuffer, (void*)&theContext, aMimeType,
PR_FALSE, PR_TRUE, aMode);
fragSink->DidBuildContent();
} else {
// Add an end tag chunk, so expat will read the whole source buffer,
// and not worry about ']]' etc.
result = Parse(aSourceBuffer + NS_LITERAL_STRING("</"),
(void*)&theContext, aMimeType, PR_FALSE, PR_FALSE, aMode);
fragSink->DidBuildContent();
if (NS_SUCCEEDED(result)) {
nsAutoString endContext;
for (theIndex = 0; theIndex < theCount; theIndex++) {
// we already added an end tag chunk above
if (theIndex > 0) {
endContext.AppendLiteral("</");
}
nsAutoString thisTag( (PRUnichar*)aTagStack.ElementAt(theIndex) );
// was there an xmlns=?
PRInt32 endOfTag = thisTag.FindChar(PRUnichar(' '));
if (endOfTag == -1) {
endContext.Append(thisTag);
} else {
endContext.Append(Substring(thisTag,0,endOfTag));
}
endContext.AppendLiteral(">");
}
result = Parse(endContext, (void*)&theContext, aMimeType,
PR_FALSE, PR_TRUE, aMode);
}
}
mFlags |= NS_PARSER_FLAG_OBSERVERS_ENABLED; //now reenable.