Intervention / mimesniffer

A library to detect mime types of binary content

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shorten JPEG pattern to match E2 tag suffix

sebluy opened this issue · comments

Hello!

I recently encountered a JPEG image with the tag FFD8FFE2, which does not match the pattern for the JPEG matcher. Because of this, the image encounters a decode error when using Intervention/Image.

protected $pattern = "/^FFD8FF(DB|E0|EE|E1)/";

All other applications I tried recognize the image as a JPEG, and as I understand it, only the first part of the tag (FFD8FF) is required to indicate the image is a JPEG. I'm curious as to why there's extra restriction in the regex, and if it's necessary.

Let me now if it would be possible to shorten the pattern to match more tags. It seems like it should be:

 protected $pattern = "/^FFD8FF/"; 

The issue still exists. By the way, I consider that it can be fixed by extending the pattern with "E2" "E3" and "E8", instead of decreasing the pattern size