-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Technically invalid test images #6878
Comments
"timeout-d675703545fee17acab56e5fec644c19979175de.eps" is also invalid. It has a valid binary header, but it doesn't contain either of the required header comments: |
It is raising a SyntaxError because the first line is longer than 255 characters. That error is caught, leading to the UnidentifiedImageError. https://www.loc.gov/preservation/digital/formats/fdd/fdd000246.shtml
|
I'm not sure it should be doing that, though. The file has a valid binary header with an offset of 32,820. That offset puts the start at column 594 of line 41 (using ANSI encoding), which appears to be binary data. So it could either raise an error because there isn't any header comments at that position, or it could assume there is no header and raise an error because the required comments are missing. Perhaps it's different with a different encoding? |
Are you saying that an UnidentifiedImageError shouldn't be raised because we actually do know what the image format is? You may want to have a look at #1687 |
I'm saying the error should be due to the missing header comments, not because the line is too long, because the line appears to be binary data, not ASCII, so it doesn't have a length limit. |
Looking at the actual specification, I see
So perhaps that leads to your conclusion that binary data can be longer than 255 characters. In trying to find out what should come after the offset though, I'm having a hard time finding more information about this. Pillow/src/PIL/EpsImagePlugin.py Lines 326 to 333 in c2e2da4
Do you happen to know where any documentation about that is? |
No, I didn't find anything other than that PDF. |
The comments regarding line length and required header comments in timeout-d675703545fee17acab56e5fec644c19979175de.eps and have been resolved by #6879. The file now raises "SyntaxError: EPS header missing "%!PS-Adobe" comment". |
"illu10_no_preview.eps", "illu10_preview.eps", "illuCS6_no_preview.eps", and "illuCS6_preview.eps" all contain one line that is longer than 255 characters, which is the maximum limit according to the specification.
Page 13:
Page 25:
The four image files appear to be nearly the same, and have the same long line:
Pillow/Tests/images/illu10_no_preview.eps
Line 7995 in 50f7888
It looks like


, an HTML encoded line feed, was added to this file instead of an actual line feed. Replacing

with\n
allowed the files to load in my branch (I'm testing some changes to the EPS plugin).The two "*_preview.eps" files also have a line that is longer than 255 characters at the end, but it looks like binary data so I think that's valid.
Currently the code only checks the line length for lines in the header, and lines after the header that start with a
%
. Since these test files came from the wild, we probably want to allow files like this, but I thought I'd at least document it.The text was updated successfully, but these errors were encountered: