Improved documentation

This commit is contained in:
Andrew Murray 2020-07-21 20:46:50 +10:00
parent 56a43a5fa7
commit 265bfef36e
2 changed files with 6 additions and 6 deletions

View File

@ -52,11 +52,11 @@ Functions
.. warning::
To protect against potential DOS attacks caused by "`decompression bombs`_" (i.e. malicious files
which decompress into a huge amount of data and are designed to crash or cause disruption by using up
a lot of memory), Pillow will issue a ``DecompressionBombWarning`` if the image is over a certain
limit. If desired, the warning can be turned into an error with
``warnings.simplefilter('error', Image.DecompressionBombWarning)`` or suppressed entirely with
``warnings.simplefilter('ignore', Image.DecompressionBombWarning)``. See also `the logging
documentation`_ to have warnings output to the logging facility instead of stderr.
a lot of memory), Pillow will issue a ``DecompressionBombWarning`` if the number of pixels in an
image is over a certain limit, :py:data:`PIL.Image.MAX_IMAGE_PIXELS`. If desired, the warning can be
turned into an error with ``warnings.simplefilter('error', Image.DecompressionBombWarning)`` or
suppressed entirely with ``warnings.simplefilter('ignore', Image.DecompressionBombWarning)``. See
also `the logging documentation`_ to have warnings output to the logging facility instead of stderr.
.. _decompression bombs: https://en.wikipedia.org/wiki/Zip_bomb
.. _the logging documentation: https://docs.python.org/3/library/logging.html#integration-with-the-warnings-module

View File

@ -81,7 +81,7 @@ class DecompressionBombError(Exception):
pass
# Limit to around a quarter gigabyte for a 24 bit (3 bpp) image
# Limit to around a quarter gigabyte for a 24-bit (3 bpp) image
MAX_IMAGE_PIXELS = int(1024 * 1024 * 1024 // 4 // 3)