From d2e0c6cd0da9a4f2e5d815f32a807757b1432543 Mon Sep 17 00:00:00 2001 From: "harishd%netscape.com" Date: Mon, 13 Jan 2003 22:05:52 +0000 Subject: [PATCH] Prevent a hang by consuming entity-look-alike ( &# ) as text. b=188278, r=heikki,sr=jst git-svn-id: svn://10.0.0.236/trunk@136261 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/nsHTMLTokens.cpp | 6 ++++++ mozilla/parser/htmlparser/src/nsHTMLTokens.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/mozilla/htmlparser/src/nsHTMLTokens.cpp b/mozilla/htmlparser/src/nsHTMLTokens.cpp index 22ab3c521ae..1b2c8b6cf03 100644 --- a/mozilla/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokens.cpp @@ -2039,6 +2039,12 @@ CEntityToken::ConsumeEntity(PRUnichar aChar, result = aScanner.Peek(theChar,2); if (NS_FAILED(result)) { + if (kEOF == result && !aScanner.IsIncremental()) { + // If this is the last buffer then we are certainly + // not dealing with an entity. That's, there are + // no more characters after &#. Bug 188278. + return NS_HTMLTOKENS_NOT_AN_ENTITY; + } return result; } diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp index 22ab3c521ae..1b2c8b6cf03 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp @@ -2039,6 +2039,12 @@ CEntityToken::ConsumeEntity(PRUnichar aChar, result = aScanner.Peek(theChar,2); if (NS_FAILED(result)) { + if (kEOF == result && !aScanner.IsIncremental()) { + // If this is the last buffer then we are certainly + // not dealing with an entity. That's, there are + // no more characters after &#. Bug 188278. + return NS_HTMLTOKENS_NOT_AN_ENTITY; + } return result; }