bpo-36260: Add pitfalls to zipfile module documentation (GH-13378) (G… · python/cpython@c5a6723 (original) (raw)

Original file line number Diff line number Diff line change
@@ -816,5 +816,45 @@ Command-line options
816 816
817 817 Test whether the zipfile is valid or not.
818 818
819 +Decompression pitfalls
820 +----------------------
821 +
822 +The extraction in zipfile module might fail due to some pitfalls listed below.
823 +
824 +From file itself
825 +~~~~~~~~~~~~~~~~
826 +
827 +Decompression may fail due to incorrect password / CRC checksum / ZIP format or
828 +unsupported compression method / decryption.
829 +
830 +File System limitations
831 +~~~~~~~~~~~~~~~~~~~~~~~
832 +
833 +Exceeding limitations on different file systems can cause decompression failed.
834 +Such as allowable characters in the directory entries, length of the file name,
835 +length of the pathname, size of a single file, and number of files, etc.
836 +
837 +Resources limitations
838 +~~~~~~~~~~~~~~~~~~~~~
839 +
840 +The lack of memory or disk volume would lead to decompression
841 +failed. For example, decompression bombs (aka `ZIP bomb`_)
842 +apply to zipfile library that can cause disk volume exhaustion.
843 +
844 +Interruption
845 +~~~~~~~~~~~~
846 +
847 +Interruption during the decompression, such as pressing control-C or killing the
848 +decompression process may result in incomplete decompression of the archive.
849 +
850 +Default behaviors of extraction
851 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
852 +
853 +Not knowing the default extraction behaviors
854 +can cause unexpected decompression results.
855 +For example, when extracting the same archive twice,
856 +it overwrites files without asking.
857 +
819 858
859 +.. _ZIP bomb: https://en.wikipedia.org/wiki/Zip\_bomb
820 860 .. _PKZIP Application Note: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT