mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-21 14:02:49 +03:00
Proper (safe) showing of safe encoded data
This commit is contained in:
parent
2b57b4b54b
commit
4d028c7230
|
@ -103,7 +103,7 @@ def stdoutencode(data):
|
||||||
|
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
try:
|
try:
|
||||||
retVal = getBytes(data or "", sys.stdout.encoding)
|
retVal = getBytes(data or "", sys.stdout.encoding, unsafe=False)
|
||||||
|
|
||||||
# Reference: http://bugs.python.org/issue1602
|
# Reference: http://bugs.python.org/issue1602
|
||||||
if IS_WIN:
|
if IS_WIN:
|
||||||
|
@ -118,7 +118,7 @@ def stdoutencode(data):
|
||||||
singleTimeWarnMessage(warnMsg)
|
singleTimeWarnMessage(warnMsg)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
retVal = getBytes(data or "")
|
retVal = getBytes(data or "", unsafe=False)
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ def encodeBase64(value, binary=True):
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
def getBytes(value, encoding=UNICODE_ENCODING, errors="strict"):
|
def getBytes(value, encoding=UNICODE_ENCODING, errors="strict", unsafe=True):
|
||||||
"""
|
"""
|
||||||
Returns byte representation of provided Unicode value
|
Returns byte representation of provided Unicode value
|
||||||
|
|
||||||
|
@ -236,13 +236,18 @@ def getBytes(value, encoding=UNICODE_ENCODING, errors="strict"):
|
||||||
|
|
||||||
if isinstance(value, six.text_type):
|
if isinstance(value, six.text_type):
|
||||||
if INVALID_UNICODE_PRIVATE_AREA:
|
if INVALID_UNICODE_PRIVATE_AREA:
|
||||||
|
if unsafe:
|
||||||
for char in xrange(0xF0000, 0xF00FF + 1):
|
for char in xrange(0xF0000, 0xF00FF + 1):
|
||||||
value = value.replace(six.unichr(char), "%s%02x" % (SAFE_HEX_MARKER, char - 0xF0000))
|
value = value.replace(six.unichr(char), "%s%02x" % (SAFE_HEX_MARKER, char - 0xF0000))
|
||||||
|
|
||||||
retVal = value.encode(encoding, errors)
|
retVal = value.encode(encoding, errors)
|
||||||
|
|
||||||
|
if unsafe:
|
||||||
retVal = re.sub(r"%s([0-9a-f]{2})" % SAFE_HEX_MARKER, lambda _: decodeHex(_.group(1)), retVal)
|
retVal = re.sub(r"%s([0-9a-f]{2})" % SAFE_HEX_MARKER, lambda _: decodeHex(_.group(1)), retVal)
|
||||||
else:
|
else:
|
||||||
retVal = value.encode(encoding, errors)
|
retVal = value.encode(encoding, errors)
|
||||||
|
|
||||||
|
if unsafe:
|
||||||
retVal = re.sub(b"\\\\x([0-9a-f]{2})", lambda _: decodeHex(_.group(1)), retVal)
|
retVal = re.sub(b"\\\\x([0-9a-f]{2})", lambda _: decodeHex(_.group(1)), retVal)
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
|
@ -18,7 +18,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.3.5.40"
|
VERSION = "1.3.5.41"
|
||||||
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