Commit eae6de2
committed
gh-153426: Raise BadZipFile for an invalid UTF-8 filename in zipfile
When a central directory or local file header entry sets the UTF-8 filename
flag (general purpose bit 11) but stores bytes that are not valid UTF-8,
opening the archive raised a raw UnicodeDecodeError instead of the
BadZipFile that signals a corrupt archive. Wrap the bit-11 filename decode
in both _RealGetContents and ZipFile.open to raise BadZipFile, mirroring
the handling of the unicode path extra field, while leaving the
metadata_encoding decode path unchanged.1 parent f3fd9dc commit eae6de2
3 files changed
Lines changed: 47 additions & 2 deletions
File tree
- Lib
- test/test_zipfile
- zipfile
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5754 | 5754 | | |
5755 | 5755 | | |
5756 | 5756 | | |
| 5757 | + | |
| 5758 | + | |
| 5759 | + | |
| 5760 | + | |
| 5761 | + | |
| 5762 | + | |
| 5763 | + | |
| 5764 | + | |
| 5765 | + | |
| 5766 | + | |
| 5767 | + | |
| 5768 | + | |
| 5769 | + | |
| 5770 | + | |
| 5771 | + | |
| 5772 | + | |
| 5773 | + | |
| 5774 | + | |
| 5775 | + | |
| 5776 | + | |
| 5777 | + | |
| 5778 | + | |
| 5779 | + | |
| 5780 | + | |
| 5781 | + | |
| 5782 | + | |
| 5783 | + | |
| 5784 | + | |
| 5785 | + | |
| 5786 | + | |
| 5787 | + | |
| 5788 | + | |
5757 | 5789 | | |
5758 | 5790 | | |
5759 | 5791 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2050 | 2050 | | |
2051 | 2051 | | |
2052 | 2052 | | |
2053 | | - | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
| 2058 | + | |
2054 | 2059 | | |
2055 | 2060 | | |
2056 | 2061 | | |
| |||
2231 | 2236 | | |
2232 | 2237 | | |
2233 | 2238 | | |
2234 | | - | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
2235 | 2245 | | |
2236 | 2246 | | |
2237 | 2247 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments