mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Use a custom subclass of RuntimeWarning for DecompressionBombWarning
This commit is contained in:
parent
195453679a
commit
46abe78b77
|
@ -31,6 +31,9 @@ from PIL import VERSION, PILLOW_VERSION, _plugins
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
|
||||||
|
class DecompressionBombWarning(RuntimeWarning):
|
||||||
|
pass
|
||||||
|
|
||||||
class _imaging_not_installed:
|
class _imaging_not_installed:
|
||||||
# module placeholder
|
# module placeholder
|
||||||
def __getattr__(self, id):
|
def __getattr__(self, id):
|
||||||
|
@ -2187,7 +2190,7 @@ def _decompression_bomb_check(size):
|
||||||
"Image size (%d pixels) exceeds limit of %d pixels, "
|
"Image size (%d pixels) exceeds limit of %d pixels, "
|
||||||
"could be decompression bomb DOS attack." %
|
"could be decompression bomb DOS attack." %
|
||||||
(pixels, MAX_IMAGE_PIXELS),
|
(pixels, MAX_IMAGE_PIXELS),
|
||||||
RuntimeWarning)
|
DecompressionBombWarning)
|
||||||
|
|
||||||
|
|
||||||
def open(fp, mode="r"):
|
def open(fp, mode="r"):
|
||||||
|
|
|
@ -31,7 +31,7 @@ def test_warning():
|
||||||
|
|
||||||
# Act / Assert
|
# Act / Assert
|
||||||
assert_warning(
|
assert_warning(
|
||||||
RuntimeWarning,
|
DecompressionBombWarning,
|
||||||
lambda: Image.open(test_file))
|
lambda: Image.open(test_file))
|
||||||
|
|
||||||
# End of file
|
# End of file
|
||||||
|
|
Loading…
Reference in New Issue
Block a user