diff --git a/modules/libpr0n/src/imgLoader.cpp b/modules/libpr0n/src/imgLoader.cpp index 39952dca00c..bac1880bcca 100644 --- a/modules/libpr0n/src/imgLoader.cpp +++ b/modules/libpr0n/src/imgLoader.cpp @@ -1459,15 +1459,21 @@ NS_IMETHODIMP imgLoader::GetMIMETypeFromContent(nsIRequest* aRequest, nsresult imgLoader::GetMimeTypeFromContent(const char* aContents, PRUint32 aLength, nsACString& aContentType) { /* Is it a GIF? */ - if (aLength >= 4 && !nsCRT::strncmp(aContents, "GIF8", 4)) { + if (aLength >= 6 && (!nsCRT::strncmp(aContents, "GIF87a", 6) || + !nsCRT::strncmp(aContents, "GIF89a", 6))) + { aContentType.AssignLiteral("image/gif"); } /* or a PNG? */ - else if (aLength >= 4 && ((unsigned char)aContents[0]==0x89 && + else if (aLength >= 8 && ((unsigned char)aContents[0]==0x89 && (unsigned char)aContents[1]==0x50 && (unsigned char)aContents[2]==0x4E && - (unsigned char)aContents[3]==0x47)) + (unsigned char)aContents[3]==0x47 && + (unsigned char)aContents[4]==0x0D && + (unsigned char)aContents[5]==0x0A && + (unsigned char)aContents[6]==0x1A && + (unsigned char)aContents[7]==0x0A)) { aContentType.AssignLiteral("image/png"); } diff --git a/netwerk/streamconv/converters/nsUnknownDecoder.cpp b/netwerk/streamconv/converters/nsUnknownDecoder.cpp index 3ceeeb46314..fa989f54318 100644 --- a/netwerk/streamconv/converters/nsUnknownDecoder.cpp +++ b/netwerk/streamconv/converters/nsUnknownDecoder.cpp @@ -60,7 +60,7 @@ #include "nsNetCID.h" -#define MAX_BUFFER_SIZE 1024 +#define MAX_BUFFER_SIZE 512 nsUnknownDecoder::nsUnknownDecoder() : mBuffer(nsnull) @@ -313,7 +313,6 @@ nsUnknownDecoder::nsSnifferEntry nsUnknownDecoder::sSnifferEntries[] = { SNIFFER_ENTRY("%PDF-", APPLICATION_PDF), SNIFFER_ENTRY("%!PS-Adobe-", APPLICATION_POSTSCRIPT), - SNIFFER_ENTRY("%! PS-Adobe-", APPLICATION_POSTSCRIPT), // Files that start with mailbox delimiters let's provisionally call // text/plain