mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 19:13:48 +03:00
Improvement for #3453
This commit is contained in:
parent
6bbfec91b4
commit
ebfcf05512
|
@ -105,52 +105,6 @@ def isListLike(value): # Cross-referenced function
|
|||
def shellExec(cmd): # Cross-referenced function
|
||||
raise NotImplementedError
|
||||
|
||||
def stdoutEncode(value):
|
||||
value = value or ""
|
||||
|
||||
if IS_WIN and IS_TTY and kb.get("codePage", -1) is None:
|
||||
output = shellExec("chcp")
|
||||
match = re.search(r": (\d{3,})", output or "")
|
||||
|
||||
if match:
|
||||
try:
|
||||
candidate = "cp%s" % match.group(1)
|
||||
codecs.lookup(candidate)
|
||||
except LookupError:
|
||||
pass
|
||||
else:
|
||||
kb.codePage = candidate
|
||||
|
||||
kb.codePage = kb.codePage or ""
|
||||
|
||||
if isinstance(value, six.text_type) and PYVERSION < "3.6":
|
||||
encoding = kb.get("codePage") or sys.stdout.encoding or UNICODE_ENCODING
|
||||
|
||||
while True:
|
||||
try:
|
||||
retVal = value.encode(encoding)
|
||||
break
|
||||
except UnicodeEncodeError as ex:
|
||||
value = value[:ex.start] + "?" + value[ex.end:]
|
||||
|
||||
if IS_WIN and PYVERSION < "3.6":
|
||||
warnMsg = "cannot properly display (some) Unicode characters "
|
||||
warnMsg += "inside Windows OS command prompt "
|
||||
warnMsg += "(https://bugs.python.org/issue1602). All "
|
||||
warnMsg += "unhandled occurrences will result in "
|
||||
warnMsg += "replacement with '?' character. Please, find "
|
||||
warnMsg += "proper character representation inside "
|
||||
warnMsg += "corresponding output files. "
|
||||
singleTimeWarnMessage(warnMsg)
|
||||
|
||||
if six.PY3:
|
||||
retVal = getUnicode(retVal, encoding)
|
||||
|
||||
else:
|
||||
retVal = value
|
||||
|
||||
return retVal
|
||||
|
||||
def jsonize(data):
|
||||
"""
|
||||
Returns JSON serialized data
|
||||
|
@ -365,3 +319,51 @@ def getText(value):
|
|||
pass
|
||||
|
||||
return retVal
|
||||
|
||||
def stdoutEncode(value):
|
||||
"""
|
||||
Returns binary representation of a given Unicode value safe for writing to stdout
|
||||
"""
|
||||
|
||||
value = value or ""
|
||||
|
||||
if IS_WIN and IS_TTY and kb.get("codePage", -1) is None:
|
||||
output = shellExec("chcp")
|
||||
match = re.search(r": (\d{3,})", output or "")
|
||||
|
||||
if match:
|
||||
try:
|
||||
candidate = "cp%s" % match.group(1)
|
||||
codecs.lookup(candidate)
|
||||
except LookupError:
|
||||
pass
|
||||
else:
|
||||
kb.codePage = candidate
|
||||
|
||||
kb.codePage = kb.codePage or ""
|
||||
|
||||
if isinstance(value, six.text_type):
|
||||
encoding = kb.get("codePage") or sys.stdout.encoding or UNICODE_ENCODING
|
||||
|
||||
while True:
|
||||
try:
|
||||
retVal = value.encode(encoding)
|
||||
break
|
||||
except UnicodeEncodeError as ex:
|
||||
value = value[:ex.start] + "?" * (ex.end - ex.start) + value[ex.end:]
|
||||
|
||||
warnMsg = "cannot properly display (some) Unicode characters "
|
||||
warnMsg += "inside your terminal ('%s') environment. All " % encoding
|
||||
warnMsg += "unhandled occurrences will result in "
|
||||
warnMsg += "replacement with '?' character. Please, find "
|
||||
warnMsg += "proper character representation inside "
|
||||
warnMsg += "corresponding output files"
|
||||
singleTimeWarnMessage(warnMsg)
|
||||
|
||||
if six.PY3:
|
||||
retVal = getUnicode(retVal, encoding)
|
||||
|
||||
else:
|
||||
retVal = value
|
||||
|
||||
return retVal
|
||||
|
|
|
@ -18,7 +18,7 @@ from lib.core.enums import OS
|
|||
from thirdparty.six import unichr as _unichr
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.3.5.138"
|
||||
VERSION = "1.3.5.139"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
|
Loading…
Reference in New Issue
Block a user