From 08aab785db3ac135e3e3e243bfd81518d75d738e Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Thu, 30 Jan 2020 14:04:12 +0800 Subject: [PATCH] Added the case to detect PDF format from file signature --- SDWebImage/Core/NSData+ImageContentType.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SDWebImage/Core/NSData+ImageContentType.m b/SDWebImage/Core/NSData+ImageContentType.m index b3b8e22b..6bce90b5 100644 --- a/SDWebImage/Core/NSData+ImageContentType.m +++ b/SDWebImage/Core/NSData+ImageContentType.m @@ -65,6 +65,15 @@ } break; } + case 0x25: { + if (data.length >= 4) { + //%PDF + NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(1, 4)] encoding:NSASCIIStringEncoding]; + if ([testString isEqualToString:@"PDF"]) { + return SDImageFormatPDF; + } + } + } } return SDImageFormatUndefined; }