Only sniff text/plain types if the channel says it's still text/plain (this may

be changed after the header is parsed by other components, eg ones listening to
HTTP notifications).  Bug 273306, r=biesi, sr=darin
This commit is contained in:
bzbarsky%mit.edu 2004-12-07 00:27:50 +00:00
Родитель f7f1f88343
Коммит b59b9c3eb3
1 изменённых файлов: 10 добавлений и 6 удалений

Просмотреть файл

@ -288,20 +288,24 @@ NS_IMETHODIMP nsDocumentOpenInfo::OnStartRequest(nsIRequest *request, nsISupport
if (httpChannel && mContentType.IsEmpty()) {
// This is our initial dispatch, and this is an HTTP channel. Check for
// the text/plain mess.
nsCAutoString contentType;
nsCAutoString contentTypeHdr;
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Type"),
contentType);
contentTypeHdr);
nsCAutoString contentType;
httpChannel->GetContentType(contentType);
// Make sure to do a case-sensitive exact match comparison here. Apache
// 1.x just sends text/plain for "unknown", while Apache 2.x sends
// text/plain with a ISO-8859-1 charset. Debian's Apache version, just to
// be different, sends text/plain with iso-8859-1 charset. Don't do
// general case-insensitive comparison, since we really want to apply this
// crap as rarely as we can.
if (contentType.EqualsLiteral("text/plain") ||
contentType.Equals(
if (contentType.EqualsLiteral("text/plain") &&
(contentTypeHdr.EqualsLiteral("text/plain") ||
contentTypeHdr.Equals(
NS_LITERAL_CSTRING("text/plain; charset=ISO-8859-1")) ||
contentType.Equals(
NS_LITERAL_CSTRING("text/plain; charset=iso-8859-1"))) {
contentTypeHdr.Equals(
NS_LITERAL_CSTRING("text/plain; charset=iso-8859-1")))) {
// Check whether we have content-encoding. If we do, don't try to detect
// the type, since that will lead to the content being automatically
// decompressed....