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.
Files changed (2) hide show
  1. package/core.js +17 -10
  2. 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
- await tokenizer.ignore(1350);
615
- const maxBufferSize = 10 * 1024 * 1024;
616
- const buffer = Buffer.alloc(Math.min(maxBufferSize, tokenizer.fileInfo.size));
617
- await tokenizer.readBuffer(buffer, {mayBeLess: true});
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
- // Check if this is an Adobe Illustrator file
620
- if (buffer.includes(Buffer.from('AIPrivateData'))) {
621
- return {
622
- ext: 'ai',
623
- mime: 'application/postscript',
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-type",
3
- "version": "18.2.0",
3
+ "version": "18.2.1",
4
4
  "description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/file-type",