From fe633c6d9638fcfff9a4d8506e7d62a9fbc38913 Mon Sep 17 00:00:00 2001 From: "ftang%netscape.com" Date: Wed, 6 Sep 2000 20:41:12 +0000 Subject: [PATCH] fix bug 50654. r=nhotta take care " in the charset --- content/html/document/src/nsHTMLDocument.cpp | 14 +++++++++++--- content/xml/document/src/nsXMLDocument.cpp | 16 ++++++++++++---- layout/html/document/src/nsHTMLDocument.cpp | 14 +++++++++++--- layout/xml/document/src/nsXMLDocument.cpp | 16 ++++++++++++---- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 7e86b7b3ad5b..b124b6dea326 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -549,9 +549,17 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, if(kNotFound != start) { start += 8; // 8 = "charset=".length - PRInt32 end = contentType.FindCharInSet(";\n\r ", start ); - if(kNotFound == end ) - end = contentType.Length(); + PRInt32 end = 0; + if(PRUnichar('"') == contentType.CharAt(start)) { + start++; + end = contentType.FindCharInSet("\"", start ); + if(kNotFound == end ) + end = contentType.Length(); + } else { + end = contentType.FindCharInSet(";\n\r ", start ); + if(kNotFound == end ) + end = contentType.Length(); + } nsAutoString theCharset; contentType.Mid(theCharset, start, end - start); nsICharsetAlias* calias = nsnull; diff --git a/content/xml/document/src/nsXMLDocument.cpp b/content/xml/document/src/nsXMLDocument.cpp index 0b60e4ccd92f..d4d89365a29f 100644 --- a/content/xml/document/src/nsXMLDocument.cpp +++ b/content/xml/document/src/nsXMLDocument.cpp @@ -326,10 +326,18 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, PRInt32 start = contentType.RFind("charset=", PR_TRUE ) ; if(kNotFound != start) { - start += 8; // 8 = "charset=".length - PRInt32 end = contentType.FindCharInSet(";\n\r ", start ); - if(kNotFound == end ) - end = contentType.Length(); + start += 8; // 8 = "charset=".length + PRInt32 end = 0; + if(PRUnichar('"') == contentType.CharAt(start)) { + start++; + end = contentType.FindCharInSet("\"", start ); + if(kNotFound == end ) + end = contentType.Length(); + } else { + end = contentType.FindCharInSet(";\n\r ", start ); + if(kNotFound == end ) + end = contentType.Length(); + } nsAutoString theCharset; contentType.Mid(theCharset, start, end - start); nsICharsetAlias* calias = nsnull; diff --git a/layout/html/document/src/nsHTMLDocument.cpp b/layout/html/document/src/nsHTMLDocument.cpp index 7e86b7b3ad5b..b124b6dea326 100644 --- a/layout/html/document/src/nsHTMLDocument.cpp +++ b/layout/html/document/src/nsHTMLDocument.cpp @@ -549,9 +549,17 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, if(kNotFound != start) { start += 8; // 8 = "charset=".length - PRInt32 end = contentType.FindCharInSet(";\n\r ", start ); - if(kNotFound == end ) - end = contentType.Length(); + PRInt32 end = 0; + if(PRUnichar('"') == contentType.CharAt(start)) { + start++; + end = contentType.FindCharInSet("\"", start ); + if(kNotFound == end ) + end = contentType.Length(); + } else { + end = contentType.FindCharInSet(";\n\r ", start ); + if(kNotFound == end ) + end = contentType.Length(); + } nsAutoString theCharset; contentType.Mid(theCharset, start, end - start); nsICharsetAlias* calias = nsnull; diff --git a/layout/xml/document/src/nsXMLDocument.cpp b/layout/xml/document/src/nsXMLDocument.cpp index 0b60e4ccd92f..d4d89365a29f 100644 --- a/layout/xml/document/src/nsXMLDocument.cpp +++ b/layout/xml/document/src/nsXMLDocument.cpp @@ -326,10 +326,18 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, PRInt32 start = contentType.RFind("charset=", PR_TRUE ) ; if(kNotFound != start) { - start += 8; // 8 = "charset=".length - PRInt32 end = contentType.FindCharInSet(";\n\r ", start ); - if(kNotFound == end ) - end = contentType.Length(); + start += 8; // 8 = "charset=".length + PRInt32 end = 0; + if(PRUnichar('"') == contentType.CharAt(start)) { + start++; + end = contentType.FindCharInSet("\"", start ); + if(kNotFound == end ) + end = contentType.Length(); + } else { + end = contentType.FindCharInSet(";\n\r ", start ); + if(kNotFound == end ) + end = contentType.Length(); + } nsAutoString theCharset; contentType.Mid(theCharset, start, end - start); nsICharsetAlias* calias = nsnull;