mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-02 23:13:23 +03:00
Minor improvement of stdoutEncode
This commit is contained in:
parent
ba05bb6064
commit
09fadc43d3
|
|
@ -170,7 +170,7 @@ ac44a343947162532dbf17bd1f9ab424f8008f677367c5ad3f9f7b715a679818 lib/core/agent
|
||||||
86a9cb82c7e7beb4730264dae20bf3b7cd87c0dcaee587367362cf319f7bb079 lib/core/bigarray.py
|
86a9cb82c7e7beb4730264dae20bf3b7cd87c0dcaee587367362cf319f7bb079 lib/core/bigarray.py
|
||||||
f6062e324fdeaacf9df0a289fc3f12f755143e3876a70cb65b38aa2e690f73c1 lib/core/common.py
|
f6062e324fdeaacf9df0a289fc3f12f755143e3876a70cb65b38aa2e690f73c1 lib/core/common.py
|
||||||
11c748cc96ea2bc507bc6c1930a17fe4bc6fdd2dd2a80430df971cb21428eb00 lib/core/compat.py
|
11c748cc96ea2bc507bc6c1930a17fe4bc6fdd2dd2a80430df971cb21428eb00 lib/core/compat.py
|
||||||
c6e54bfb1e3bc116ced8d525978ba3f4a10a59b99bc48d895b73359df0682d9b lib/core/convert.py
|
e5eae3c41fbe525326a14fa240882ba7e1083e0fc0561f15c9ae41a4592d3f53 lib/core/convert.py
|
||||||
ae500647c4074681749735a4f3b17b7eca44868dd3f39f9cab0a575888ba04a1 lib/core/data.py
|
ae500647c4074681749735a4f3b17b7eca44868dd3f39f9cab0a575888ba04a1 lib/core/data.py
|
||||||
b22decc8389c94a13f1adf07eb343cf3b2aae3fb3909fd4107e24bbede7c7deb lib/core/datatype.py
|
b22decc8389c94a13f1adf07eb343cf3b2aae3fb3909fd4107e24bbede7c7deb lib/core/datatype.py
|
||||||
253309dc355ae27cd275e7de5a068e7e22feba603c4fe3429e2b69f8a51c0d13 lib/core/decorators.py
|
253309dc355ae27cd275e7de5a068e7e22feba603c4fe3429e2b69f8a51c0d13 lib/core/decorators.py
|
||||||
|
|
@ -190,7 +190,7 @@ c4bfb493a03caf84dd362aec7c248097841de804b7413d0e1ecb8a90c8550bc0 lib/core/readl
|
||||||
d1bd70c1a55858495c727fbec91e30af267459c8f64d50fabf9e4ee2c007e920 lib/core/replication.py
|
d1bd70c1a55858495c727fbec91e30af267459c8f64d50fabf9e4ee2c007e920 lib/core/replication.py
|
||||||
1d0f80b0193ac5204527bfab4bde1a7aee0f693fd008e86b4b29f606d1ef94f3 lib/core/revision.py
|
1d0f80b0193ac5204527bfab4bde1a7aee0f693fd008e86b4b29f606d1ef94f3 lib/core/revision.py
|
||||||
d2eb8e4b05ac93551272b3d4abfaf5b9f2d3ac92499a7704c16ed0b4f200db38 lib/core/session.py
|
d2eb8e4b05ac93551272b3d4abfaf5b9f2d3ac92499a7704c16ed0b4f200db38 lib/core/session.py
|
||||||
72affdfd108cd7c4c10b54389917b018731e592a5f8e087c38e14620bea551d0 lib/core/settings.py
|
f869523fb2f64f4cb415ede7dda998b903dfd885c6a65b860e4f572497675181 lib/core/settings.py
|
||||||
1c5eab9494eb969bc9ce118a2ea6954690c6851cbe54c18373c723b99734bf09 lib/core/shell.py
|
1c5eab9494eb969bc9ce118a2ea6954690c6851cbe54c18373c723b99734bf09 lib/core/shell.py
|
||||||
4eea6dcf023e41e3c64b210cb5c2efc7ca893b727f5e49d9c924f076bb224053 lib/core/subprocessng.py
|
4eea6dcf023e41e3c64b210cb5c2efc7ca893b727f5e49d9c924f076bb224053 lib/core/subprocessng.py
|
||||||
cdd352e1331c6b535e780f6edea79465cb55af53aa2114dcea0e8bf382e56d1a lib/core/target.py
|
cdd352e1331c6b535e780f6edea79465cb55af53aa2114dcea0e8bf382e56d1a lib/core/target.py
|
||||||
|
|
|
||||||
|
|
@ -405,10 +405,13 @@ def getText(value, encoding=None):
|
||||||
|
|
||||||
def stdoutEncode(value):
|
def stdoutEncode(value):
|
||||||
"""
|
"""
|
||||||
Returns binary representation of a given Unicode value safe for writing to stdout
|
Returns textual representation of a given value safe for writing to stdout
|
||||||
|
>>> stdoutEncode(b"foobar")
|
||||||
|
'foobar'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
value = value or ""
|
if value is None:
|
||||||
|
value = ""
|
||||||
|
|
||||||
if IS_WIN and IS_TTY and kb.get("codePage", -1) is None:
|
if IS_WIN and IS_TTY and kb.get("codePage", -1) is None:
|
||||||
output = shellExec("chcp")
|
output = shellExec("chcp")
|
||||||
|
|
@ -418,36 +421,32 @@ def stdoutEncode(value):
|
||||||
try:
|
try:
|
||||||
candidate = "cp%s" % match.group(1)
|
candidate = "cp%s" % match.group(1)
|
||||||
codecs.lookup(candidate)
|
codecs.lookup(candidate)
|
||||||
except LookupError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
kb.codePage = candidate
|
kb.codePage = candidate
|
||||||
|
except (LookupError, TypeError):
|
||||||
|
pass
|
||||||
|
|
||||||
kb.codePage = kb.codePage or ""
|
kb.codePage = kb.codePage or ""
|
||||||
|
|
||||||
if isinstance(value, six.text_type):
|
encoding = kb.get("codePage") or getattr(sys.stdout, "encoding", None) or UNICODE_ENCODING
|
||||||
encoding = kb.get("codePage") or getattr(sys.stdout, "encoding", None) or UNICODE_ENCODING
|
|
||||||
|
|
||||||
while True:
|
if six.PY3:
|
||||||
try:
|
if isinstance(value, (bytes, bytearray)):
|
||||||
retVal = value.encode(encoding)
|
value = getUnicode(value, encoding)
|
||||||
break
|
elif not isinstance(value, str):
|
||||||
except UnicodeEncodeError as ex:
|
value = str(value)
|
||||||
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)
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
retVal = value.encode(encoding, errors="replace").decode(encoding, errors="replace")
|
||||||
|
except (LookupError, TypeError):
|
||||||
|
retVal = value.encode("ascii", errors="replace").decode("ascii", errors="replace")
|
||||||
else:
|
else:
|
||||||
retVal = value
|
if isinstance(value, six.text_type):
|
||||||
|
try:
|
||||||
|
retVal = value.encode(encoding, errors="replace")
|
||||||
|
except (LookupError, TypeError):
|
||||||
|
retVal = value.encode("ascii", errors="replace")
|
||||||
|
else:
|
||||||
|
retVal = value
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ from lib.core.enums import OS
|
||||||
from thirdparty import six
|
from thirdparty import six
|
||||||
|
|
||||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||||
VERSION = "1.9.12.53"
|
VERSION = "1.9.12.54"
|
||||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
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)
|
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