mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 09:56:17 +03:00
fix tiff exif loading in case when file is empty or ended
This commit is contained in:
parent
63f5f68837
commit
9930b05a33
|
@ -1,5 +1,8 @@
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
|
import io
|
||||||
|
import struct
|
||||||
|
|
||||||
from helper import unittest, PillowTestCase, hopper
|
from helper import unittest, PillowTestCase, hopper
|
||||||
|
|
||||||
from PIL import Image, TiffImagePlugin, TiffTags
|
from PIL import Image, TiffImagePlugin, TiffTags
|
||||||
|
@ -136,6 +139,15 @@ class TestFileTiffMetadata(PillowTestCase):
|
||||||
self.assertEqual(tag_ids['MakerNoteSafety'], 50741)
|
self.assertEqual(tag_ids['MakerNoteSafety'], 50741)
|
||||||
self.assertEqual(tag_ids['BestQualityScale'], 50780)
|
self.assertEqual(tag_ids['BestQualityScale'], 50780)
|
||||||
|
|
||||||
|
def test_empty_metadata(self):
|
||||||
|
f = io.BytesIO(b'II*\x00\x08\x00\x00\x00')
|
||||||
|
head = f.read(8)
|
||||||
|
info = TiffImagePlugin.ImageFileDirectory(head)
|
||||||
|
try:
|
||||||
|
self.assert_warning(UserWarning, lambda: info.load(f))
|
||||||
|
except struct.error:
|
||||||
|
self.fail("Should not be struct errors there.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user