Ensure that we call WillBuildModel. bug 420008, r+sr=bzbarsky
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 15 Jul 2008 11:35:07 +0200
changeset 15946 2a44521bb5f7c617cb90315ca16577606f6a8163
parent 15945 23f7948191ec29162083e16e20eede470ca3b839
child 15947 9cab6554987723b656d974bebf98933506790174
push idunknown
push userunknown
push dateunknown
bugs420008
milestone1.9.1a1pre
Ensure that we call WillBuildModel. bug 420008, r+sr=bzbarsky
parser/htmlparser/src/nsParser.cpp
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -1488,16 +1488,22 @@ nsParser::ParseFragment(const nsAString&
   mFlags &= ~NS_PARSER_FLAG_OBSERVERS_ENABLED;
 
   for (theIndex = 0; theIndex < theCount; theIndex++) {
     theContext.AppendLiteral("<");
     theContext.Append(aTagStack[theCount - theIndex - 1]);
     theContext.AppendLiteral(">");
   }
 
+  if (theCount == 0) {
+    // Ensure that the buffer is not empty. Because none of the DTDs care
+    // about leading whitespace, this doesn't change the result.
+    theContext.AssignLiteral(" ");
+  }
+
   // First, parse the context to build up the DTD's tag stack. Note that we
   // pass PR_FALSE for the aLastCall parameter.
   result = Parse(theContext, (void*)&theContext, aMimeType, PR_FALSE, aMode);
   if (NS_FAILED(result)) {
     mFlags |= NS_PARSER_FLAG_OBSERVERS_ENABLED;
     return result;
   }