mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 465007. Harmonize content sniffing in HTML5 and Firefox. r=jdrew,sr=bzbarsky
This commit is contained in:
parent
6c97d783fc
commit
1bea884aa2
@ -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");
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user