зеркало из https://github.com/openwpm/OpenWPM.git
Add error handling for zlib decompression errors when decompressing javascript from proxy
This commit is contained in:
Родитель
8240733da6
Коммит
9c2473e133
|
@ -82,9 +82,17 @@ def save_javascript_content(logger, browser_params, manager_params, msg):
|
|||
# Firefox currently only accepts gzip/deflate
|
||||
script = ''
|
||||
if 'gzip' in msg.response.headers['Content-Encoding']:
|
||||
script = zlib.decompress(msg.response.content, zlib.MAX_WBITS|16)
|
||||
try:
|
||||
script = zlib.decompress(msg.response.content, zlib.MAX_WBITS|16)
|
||||
except zlib.error as e:
|
||||
logger.error('Received zlib error when trying to decompress gzipped javascript: %s' % str(e))
|
||||
return
|
||||
elif 'deflate' in msg.response.headers['Content-Encoding']:
|
||||
script = zlib.decompress(msg.response.content, -zlib.MAX_WBITS)
|
||||
try:
|
||||
script = zlib.decompress(msg.response.content, -zlib.MAX_WBITS)
|
||||
except zlib.error as e:
|
||||
logger.error('Received zlib error when trying to decompress deflated javascript: %s' % str(e))
|
||||
return
|
||||
elif msg.response.headers['Content-Encoding'] == []:
|
||||
script = msg.response.content
|
||||
else:
|
||||
|
|
Загрузка…
Ссылка в новой задаче