Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d148694

Browse files
committed
Minor refactoring
1 parent 9404b63 commit d148694

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.1.11.8"
22+
VERSION = "1.1.11.9"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/request/basic.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,22 @@ def decodePage(page, contentEncoding, contentType):
254254
if not page or (conf.nullConnection and len(page) < 2):
255255
return getUnicode(page)
256256

257-
if isinstance(contentEncoding, basestring) and contentEncoding.lower() in ("gzip", "x-gzip", "deflate"):
257+
if isinstance(contentEncoding, basestring) and contentEncoding:
258+
contentEncoding = contentEncoding.lower()
259+
else:
260+
contentEncoding = ""
261+
262+
if isinstance(contentType, basestring) and contentType:
263+
contentType = contentType.lower()
264+
else:
265+
contentType = ""
266+
267+
if contentEncoding in ("gzip", "x-gzip", "deflate"):
258268
if not kb.pageCompress:
259269
return None
260270

261271
try:
262-
if contentEncoding.lower() == "deflate":
272+
if contentEncoding == "deflate":
263273
data = StringIO.StringIO(zlib.decompress(page, -15)) # Reference: http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
264274
else:
265275
data = gzip.GzipFile("", "rb", 9, StringIO.StringIO(page))
@@ -284,7 +294,7 @@ def decodePage(page, contentEncoding, contentType):
284294
httpCharset, metaCharset = None, None
285295

286296
# Reference: http://stackoverflow.com/questions/1020892/python-urllib2-read-to-unicode
287-
if contentType and (contentType.find("charset=") != -1):
297+
if contentType.find("charset=") != -1:
288298
httpCharset = checkCharEncoding(contentType.split("charset=")[-1])
289299

290300
metaCharset = checkCharEncoding(extractRegexResult(META_CHARSET_REGEX, page))
@@ -300,7 +310,7 @@ def decodePage(page, contentEncoding, contentType):
300310
kb.pageEncoding = conf.encoding
301311

302312
# can't do for all responses because we need to support binary files too
303-
if contentType and not isinstance(page, unicode) and "text/" in contentType.lower():
313+
if not isinstance(page, unicode) and "text/" in contentType:
304314
if kb.heuristicMode:
305315
kb.pageEncoding = kb.pageEncoding or checkCharEncoding(getHeuristicCharEncoding(page))
306316
page = getUnicode(page, kb.pageEncoding)

txt/checksum.md5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ec6a778b0e74749b916caead78ba88b7 lib/core/option.py
4646
760d9df2a27ded29109b390ab202e72d lib/core/replication.py
4747
a2466b62e67f8b31736bac4dac590e51 lib/core/revision.py
4848
02d4762140a72fd44668d3dab5eabda9 lib/core/session.py
49-
15a317ddbd48bdf94e1642df57664790 lib/core/settings.py
49+
4092cefeab1270e5f9a987582eb1c099 lib/core/settings.py
5050
35bffbad762eb9e03db9e93b1c991103 lib/core/shell.py
5151
a59ec28371ae067a6fdd8f810edbee3d lib/core/subprocessng.py
5252
7c9f2af3c0a8dd89223cfe07b0a0b826 lib/core/target.py

0 commit comments

Comments
 (0)