Fixing a potential deflate issues
Some checks failed
/ build (macos-latest, 3.8) (push) Has been cancelled
/ build (ubuntu-latest, pypy-2.7) (push) Has been cancelled
/ build (windows-latest, 3.14) (push) Has been cancelled

This commit is contained in:
Your Name 2026-05-15 22:11:23 +02:00
parent d77e925a10
commit e659543048
3 changed files with 8 additions and 3 deletions

View file

@ -297,6 +297,11 @@ def decodePage(page, contentEncoding, contentType, percentDecode=True):
if contentEncoding == "deflate":
obj = zlib.decompressobj(-15)
page = obj.decompress(page, MAX_CONNECTION_TOTAL_SIZE + 1)
# catch the deflate bomb before flush() forcefully expands it into RAM
if len(page) > MAX_CONNECTION_TOTAL_SIZE:
raise Exception("size too large")
page += obj.flush()
if len(page) > MAX_CONNECTION_TOTAL_SIZE:
raise Exception("size too large")