Skip to content

Conversation

zakajd
Copy link
Contributor

@zakajd zakajd commented Sep 5, 2024

Fixes #8348

Changes proposed in this pull request:

  • Explicitly check for double exif info and drop it

@radarhere radarhere changed the title Handle dublicate exif header Handle duplicate EXIF header Sep 5, 2024
@radarhere radarhere added the Exif label Sep 5, 2024
src/PIL/Image.py Outdated
Comment on lines 3971 to 3973
if data and data.startswith(b"Exif\x00\x00Exif\x00\x00"):
data = data[12:]
elif data and data.startswith(b"Exif\x00\x00"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if data and data.startswith(b"Exif\x00\x00Exif\x00\x00"):
data = data[12:]
elif data and data.startswith(b"Exif\x00\x00"):
while data and data.startswith(b"Exif\x00\x00"):

This seems simpler to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also added test for this problem as well

@radarhere
Copy link
Member

In the issue, you said

This image is uploaded by one of the clients

Are you sure that this is an image that can be distributed under the Pillow license?

@zakajd
Copy link
Contributor Author

zakajd commented Sep 5, 2024

Good point. I'm not a lawyer, to be safe will manually create an image where the EXIF is broken same way.

Co-authored-by: Jamil Zakirov <[email protected]>
@hugovk hugovk merged commit f06b851 into python-pillow:main Sep 7, 2024
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error reading EXIF from file: SyntaxError: not a TIFF file (header b'' not valid)

3 participants