зеркало из https://github.com/mozilla/pjs.git
Bug 465007. Harmonize content sniffing in HTML5 and Firefox. r=jdrew,sr=bzbarsky
This commit is contained in:
Родитель
814ccae327
Коммит
859398b84c
|
@ -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)
|
||||
|
@ -312,7 +312,6 @@ PRBool nsUnknownDecoder::AllowSniffing(nsIRequest* aRequest)
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче