diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp
index e125a3a8c3e..3e0127f6002 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp
@@ -2109,6 +2109,9 @@ nsHTMLDocument::Close()
NS_GENERATE_PARSER_KEY(),
mContentType, PR_FALSE,
PR_TRUE);
+ } else {
+ rv = mParser->Parse(EmptyString(), NS_GENERATE_PARSER_KEY(),
+ mContentType, PR_FALSE, PR_TRUE);
}
--mWriteLevel;
mIsWriting = 0;
diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp
index 750ed637342..275b1e12c95 100644
--- a/mozilla/parser/htmlparser/src/nsParser.cpp
+++ b/mozilla/parser/htmlparser/src/nsParser.cpp
@@ -1696,10 +1696,12 @@ nsParser::Parse(const nsAString& aSourceBuffer,
nsresult result=NS_OK;
- if(aLastCall && aSourceBuffer.IsEmpty()) {
+ if(!aLastCall && aSourceBuffer.IsEmpty()) {
// Nothing is being passed to the parser so return
// immediately. mUnusedInput will get processed when
// some data is actually passed in.
+ // But if this is the last call, make sure to finish up
+ // stuff correctly.
return result;
}
@@ -1712,7 +1714,7 @@ nsParser::Parse(const nsAString& aSourceBuffer,
// till we're completely done.
nsCOMPtr kungFuDeathGrip(this);
- if(!aSourceBuffer.IsEmpty() || !mUnusedInput.IsEmpty()) {
+ if(aLastCall || !aSourceBuffer.IsEmpty() || !mUnusedInput.IsEmpty()) {
if (aVerifyEnabled) {
mFlags |= NS_PARSER_FLAG_DTD_VERIFICATION;
@@ -1777,7 +1779,7 @@ nsParser::Parse(const nsAString& aSourceBuffer,
pc->mDTDMode = aMode;
}
- mUnusedInput.Truncate(0);
+ mUnusedInput.Truncate();
//printf("Parse(string) iterate: %i",PR_FALSE);
pc->mScanner->Append(aSourceBuffer);