file-type 18.2.0 → 18.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core.js +17 -10
- package/package.json +1 -1
package/core.js
CHANGED
|
@@ -611,17 +611,24 @@ class FileTypeParser {
|
|
|
611
611
|
}
|
|
612
612
|
|
|
613
613
|
if (this.checkString('%PDF')) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
614
|
+
try {
|
|
615
|
+
await tokenizer.ignore(1350);
|
|
616
|
+
const maxBufferSize = 10 * 1024 * 1024;
|
|
617
|
+
const buffer = Buffer.alloc(Math.min(maxBufferSize, tokenizer.fileInfo.size));
|
|
618
|
+
await tokenizer.readBuffer(buffer, {mayBeLess: true});
|
|
618
619
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
620
|
+
// Check if this is an Adobe Illustrator file
|
|
621
|
+
if (buffer.includes(Buffer.from('AIPrivateData'))) {
|
|
622
|
+
return {
|
|
623
|
+
ext: 'ai',
|
|
624
|
+
mime: 'application/postscript',
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
} catch (error) {
|
|
628
|
+
// Swallow end of stream error if file is too small for the Adobe AI check
|
|
629
|
+
if (!(error instanceof strtok3.EndOfStreamError)) {
|
|
630
|
+
throw error;
|
|
631
|
+
}
|
|
625
632
|
}
|
|
626
633
|
|
|
627
634
|
// Assume this is just a normal PDF
|