From 8cb3795a6a8bc9e974eb2aeed01cfbdf78ca24cc Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Thu, 13 Jan 2000 23:22:25 +0000 Subject: [PATCH] r=gagan. 17647. we digesting content-type comments as legitimate header values. now we're not git-svn-id: svn://10.0.0.236/trunk@57714 18797224-902f-48f8-a5cc-f745e15eee43 --- .../protocol/http/src/nsHTTPResponse.cpp | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp index 6d2dbe3d400..c82b918da03 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPResponse.cpp @@ -373,28 +373,32 @@ nsresult nsHTTPResponse::ProcessHeader(nsIAtom* aHeader, nsCString& aValue) nsCAutoString buffer; PRInt32 semicolon; - // Set the content-type in the HTTPChannel... - semicolon = aValue.FindChar(';'); - if (kNotFound != semicolon) { - aValue.Left(buffer, semicolon); - SetContentType(buffer.GetBuffer()); + // we don't care about comments + PRInt32 parenLoc = aValue.FindChar('('); + if (parenLoc > -1) { + aValue.Truncate(parenLoc); + aValue.Trim(" ", PR_FALSE); + } - // Does the Content-Type contain a charset attribute? - aValue.Mid(buffer, semicolon+1, -1); - buffer.Trim(" "); - if (0 == buffer.Find("charset=", PR_TRUE)) { - // - // Set the charset in the HTTPChannel... - // - // XXX: Currently, the charset is *everything* past the "charset=" - // This includes comments :-( - // - buffer.Cut(0, 8); - SetCharset(buffer.GetBuffer()); + if (!aValue.IsEmpty()) { + // Set the content-type in the HTTPChannel... + semicolon = aValue.FindChar(';'); + if (kNotFound != semicolon) { + aValue.Left(buffer, semicolon); + SetContentType(buffer.GetBuffer()); + + // Does the Content-Type contain a charset attribute? + aValue.Mid(buffer, semicolon+1, -1); + buffer.Trim(" "); + if (0 == buffer.Find("charset=", PR_TRUE)) { + // Set the charset in the HTTPChannel... + buffer.Cut(0, 8); + SetCharset(buffer.GetBuffer()); + } + } + else { + SetContentType(aValue.GetBuffer()); } - } - else { - SetContentType(aValue.GetBuffer()); } } //