From 826f91eada4b379020a9ba937a5d592b057c630f Mon Sep 17 00:00:00 2001 From: "heikki%netscape.com" Date: Tue, 3 Jun 2003 17:47:10 +0000 Subject: [PATCH] Bug 207904, doctype with name only got destroyed by our doctype handling, r=harishd, sr=jst. --- htmlparser/src/nsExpatDriver.cpp | 9 +++++++-- parser/htmlparser/src/nsExpatDriver.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/htmlparser/src/nsExpatDriver.cpp b/htmlparser/src/nsExpatDriver.cpp index 43bb424d42e..30b7ac68bac 100644 --- a/htmlparser/src/nsExpatDriver.cpp +++ b/htmlparser/src/nsExpatDriver.cpp @@ -504,6 +504,8 @@ nsExpatDriver::HandleEndCdataSection() * detected errors. The only slightly problematic case is whitespace * between the tokens. There MUST be whitespace between the tokens * EXCEPT right before > and [. + * + * We assume the string will not contain the ending '>'. */ static void GetDocTypeToken(nsString& aStr, @@ -516,9 +518,12 @@ GetDocTypeToken(nsString& aStr, PRInt32 endQuote = aStr.FindChar(aStr[0],1); aStr.Mid(aToken,1,endQuote-1); aStr.Cut(0,endQuote+1); - } else { - static const char* kDelimiter = " >[\r\n\t"; // Optimized for typical cases + } else { + static const char* kDelimiter = " [\r\n\t"; // Optimized for typical cases PRInt32 tokenEnd = aStr.FindCharInSet(kDelimiter); + if (tokenEnd < 0) { + tokenEnd = aStr.Length(); + } if (tokenEnd > 0) { aStr.Left(aToken, tokenEnd); aStr.Cut(0, tokenEnd); diff --git a/parser/htmlparser/src/nsExpatDriver.cpp b/parser/htmlparser/src/nsExpatDriver.cpp index 43bb424d42e..30b7ac68bac 100644 --- a/parser/htmlparser/src/nsExpatDriver.cpp +++ b/parser/htmlparser/src/nsExpatDriver.cpp @@ -504,6 +504,8 @@ nsExpatDriver::HandleEndCdataSection() * detected errors. The only slightly problematic case is whitespace * between the tokens. There MUST be whitespace between the tokens * EXCEPT right before > and [. + * + * We assume the string will not contain the ending '>'. */ static void GetDocTypeToken(nsString& aStr, @@ -516,9 +518,12 @@ GetDocTypeToken(nsString& aStr, PRInt32 endQuote = aStr.FindChar(aStr[0],1); aStr.Mid(aToken,1,endQuote-1); aStr.Cut(0,endQuote+1); - } else { - static const char* kDelimiter = " >[\r\n\t"; // Optimized for typical cases + } else { + static const char* kDelimiter = " [\r\n\t"; // Optimized for typical cases PRInt32 tokenEnd = aStr.FindCharInSet(kDelimiter); + if (tokenEnd < 0) { + tokenEnd = aStr.Length(); + } if (tokenEnd > 0) { aStr.Left(aToken, tokenEnd); aStr.Cut(0, tokenEnd);