mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-03 05:04:11 +03:00
major bug fix (different HTTP content charsets are now properly handled)
This commit is contained in:
parent
654d707d5d
commit
eaef068c90
|
@ -89,13 +89,13 @@ def parseResponse(page, headers):
|
|||
kb.absFilePaths.add(absFilePath)
|
||||
|
||||
|
||||
def decodePage(page, encoding):
|
||||
def decodePage(page, contentEncoding, contentType):
|
||||
"""
|
||||
Decode gzip/deflate HTTP response
|
||||
Decode compressed/charset HTTP response
|
||||
"""
|
||||
|
||||
if isinstance(encoding, basestring) and encoding.lower() in ('gzip', 'x-gzip', 'deflate'):
|
||||
if encoding == 'deflate':
|
||||
if isinstance(contentEncoding, basestring) and contentEncoding.lower() in ('gzip', 'x-gzip', 'deflate'):
|
||||
if contentEncoding == 'deflate':
|
||||
# http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
|
||||
data = StringIO.StringIO(zlib.decompress(page, -15))
|
||||
else:
|
||||
|
@ -103,4 +103,8 @@ def decodePage(page, encoding):
|
|||
|
||||
page = data.read()
|
||||
|
||||
#http://stackoverflow.com/questions/1020892/python-urllib2-read-to-unicode
|
||||
if contentType and (contentType.find('charset=') != -1):
|
||||
page = unicode(page, contentType.split('charset=')[-1])
|
||||
|
||||
return page
|
||||
|
|
|
@ -106,8 +106,7 @@ class Connect:
|
|||
page = conn.read()
|
||||
responseHeaders = conn.info()
|
||||
|
||||
encoding = responseHeaders.get("Content-Encoding")
|
||||
page = decodePage(page, encoding)
|
||||
page = decodePage(page, responseHeaders.get("Content-Encoding"), responseHeaders.get("Content-Type"))
|
||||
|
||||
return page
|
||||
|
||||
|
@ -190,8 +189,7 @@ class Connect:
|
|||
status = conn.msg
|
||||
responseHeaders = conn.info()
|
||||
|
||||
encoding = responseHeaders.get("Content-Encoding")
|
||||
page = decodePage(page, encoding)
|
||||
page = decodePage(page, responseHeaders.get("Content-Encoding"), responseHeaders.get("Content-Type"))
|
||||
|
||||
except urllib2.HTTPError, e:
|
||||
if e.code == 401:
|
||||
|
|
Loading…
Reference in New Issue
Block a user