From 74b5c71041da3cdc6ff24f3349db566656f9cc17 Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Thu, 2 Jun 2005 23:36:43 +0000 Subject: [PATCH] bug 296212: If the very last character in a document is an &, it gets lost (in both view-source and regular content). r=jst sr=bzbarsky a=chofmann git-svn-id: svn://10.0.0.236/trunk@174096 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp index 070780e8077..a87adbd15a1 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp @@ -1,4 +1,5 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set sw=2 ts=2 et tw=78: */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -1037,7 +1038,7 @@ nsresult nsHTMLTokenizer::ConsumeEntity(PRUnichar aChar, IF_FREE(aToken, mTokenAllocator); } else { - if (mIsFinalChunk && result == kEOF) { + if (!aScanner.IsIncremental() && result == kEOF) { result=NS_OK; // Use as much of the entity as you can get. } AddToken(aToken,result,&mTokenDeque,theAllocator); @@ -1047,6 +1048,13 @@ nsresult nsHTMLTokenizer::ConsumeEntity(PRUnichar aChar, // Oops, we're actually looking at plain text... result = ConsumeText(aToken,aScanner); } + else if (result == kEOF && !aScanner.IsIncremental()) { + // If the last character in the file is an &, consume it as text. + result = ConsumeText(aToken, aScanner); + if (aToken) { + aToken->SetInError(PR_TRUE); + } + } return result; }