File tree 1 file changed +13
-11
lines changed
1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -726,17 +726,19 @@ export class FileTypeParser {
726
726
727
727
if ( this . checkString ( '%PDF' ) ) {
728
728
try {
729
- await tokenizer . ignore ( 1350 ) ;
730
- const maxBufferSize = 10 * 1024 * 1024 ;
731
- const buffer = new Uint8Array ( Math . min ( maxBufferSize , tokenizer . fileInfo . size ) ) ;
732
- await tokenizer . readBuffer ( buffer , { mayBeLess : true } ) ;
733
-
734
- // Check if this is an Adobe Illustrator file
735
- if ( includes ( buffer , new TextEncoder ( ) . encode ( 'AIPrivateData' ) ) ) {
736
- return {
737
- ext : 'ai' ,
738
- mime : 'application/postscript' ,
739
- } ;
729
+ const skipBytes = 1350 ;
730
+ if ( skipBytes === await tokenizer . ignore ( skipBytes ) ) {
731
+ const maxBufferSize = 10 * 1024 * 1024 ;
732
+ const buffer = new Uint8Array ( Math . min ( maxBufferSize , tokenizer . fileInfo . size - skipBytes ) ) ;
733
+ await tokenizer . readBuffer ( buffer , { mayBeLess : true } ) ;
734
+
735
+ // Check if this is an Adobe Illustrator file
736
+ if ( includes ( buffer , new TextEncoder ( ) . encode ( 'AIPrivateData' ) ) ) {
737
+ return {
738
+ ext : 'ai' ,
739
+ mime : 'application/postscript' ,
740
+ } ;
741
+ }
740
742
}
741
743
} catch ( error ) {
742
744
// Swallow end of stream error if file is too small for the Adobe AI check
You can’t perform that action at this time.
0 commit comments