mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-28 20:43:49 +03:00
Minor improvement of table dump formatting
This commit is contained in:
parent
eec9cca85b
commit
a75ab8b128
|
@ -263,7 +263,7 @@ def getOrds(value):
|
||||||
|
|
||||||
def getUnicode(value, encoding=None, noneToNull=False):
|
def getUnicode(value, encoding=None, noneToNull=False):
|
||||||
"""
|
"""
|
||||||
Return the unicode representation of the supplied value:
|
Returns the unicode representation of the supplied value
|
||||||
|
|
||||||
>>> getUnicode('test') == u'test'
|
>>> getUnicode('test') == u'test'
|
||||||
True
|
True
|
||||||
|
@ -375,3 +375,20 @@ def stdoutEncode(value):
|
||||||
retVal = value
|
retVal = value
|
||||||
|
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
|
def getConsoleLength(value):
|
||||||
|
"""
|
||||||
|
Returns console width of unicode values
|
||||||
|
|
||||||
|
>>> getConsoleLength("abc")
|
||||||
|
3
|
||||||
|
>>> getConsoleLength(u"\\u957f\\u6c5f")
|
||||||
|
4
|
||||||
|
"""
|
||||||
|
|
||||||
|
if isinstance(value, six.text_type):
|
||||||
|
retVal = sum((2 if ord(_) >= 0x3000 else 1) for _ in value)
|
||||||
|
else:
|
||||||
|
retVal = len(value)
|
||||||
|
|
||||||
|
return retVal
|
|
@ -28,6 +28,7 @@ from lib.core.common import safeCSValue
|
||||||
from lib.core.common import unsafeSQLIdentificatorNaming
|
from lib.core.common import unsafeSQLIdentificatorNaming
|
||||||
from lib.core.compat import xrange
|
from lib.core.compat import xrange
|
||||||
from lib.core.convert import getBytes
|
from lib.core.convert import getBytes
|
||||||
|
from lib.core.convert import getConsoleLength
|
||||||
from lib.core.convert import getText
|
from lib.core.convert import getText
|
||||||
from lib.core.convert import getUnicode
|
from lib.core.convert import getUnicode
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
|
@ -547,7 +548,7 @@ class Dump(object):
|
||||||
|
|
||||||
column = unsafeSQLIdentificatorNaming(column)
|
column = unsafeSQLIdentificatorNaming(column)
|
||||||
maxlength = int(info["length"])
|
maxlength = int(info["length"])
|
||||||
blank = " " * (maxlength - len(column))
|
blank = " " * (maxlength - getConsoleLength(column))
|
||||||
|
|
||||||
self._write("| %s%s" % (column, blank), newline=False)
|
self._write("| %s%s" % (column, blank), newline=False)
|
||||||
|
|
||||||
|
@ -602,7 +603,7 @@ class Dump(object):
|
||||||
|
|
||||||
values.append(value)
|
values.append(value)
|
||||||
maxlength = int(info["length"])
|
maxlength = int(info["length"])
|
||||||
blank = " " * (maxlength - len(value))
|
blank = " " * (maxlength - getConsoleLength(value))
|
||||||
self._write("| %s%s" % (value, blank), newline=False, console=console)
|
self._write("| %s%s" % (value, blank), newline=False, console=console)
|
||||||
|
|
||||||
if len(value) > MIN_BINARY_DISK_DUMP_SIZE and r'\x' in value:
|
if len(value) > MIN_BINARY_DISK_DUMP_SIZE and r'\x' in value:
|
||||||
|
|
|
@ -18,7 +18,7 @@ from lib.core.enums import OS
|
||||||
from thirdparty.six import unichr as _unichr
|
from thirdparty.six import unichr as _unichr
|
||||||
|
|
||||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||||
VERSION = "1.3.10.28"
|
VERSION = "1.3.10.29"
|
||||||
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)
|
||||||
|
|
|
@ -25,6 +25,7 @@ from lib.core.common import singleTimeLogMessage
|
||||||
from lib.core.common import singleTimeWarnMessage
|
from lib.core.common import singleTimeWarnMessage
|
||||||
from lib.core.common import unArrayizeValue
|
from lib.core.common import unArrayizeValue
|
||||||
from lib.core.common import unsafeSQLIdentificatorNaming
|
from lib.core.common import unsafeSQLIdentificatorNaming
|
||||||
|
from lib.core.convert import getConsoleLength
|
||||||
from lib.core.convert import getUnicode
|
from lib.core.convert import getUnicode
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
|
@ -269,7 +270,7 @@ class Entries(object):
|
||||||
else:
|
else:
|
||||||
colEntry = unArrayizeValue(entry[index]) if index < len(entry) else u''
|
colEntry = unArrayizeValue(entry[index]) if index < len(entry) else u''
|
||||||
|
|
||||||
maxLen = max(len(column), len(DUMP_REPLACEMENTS.get(getUnicode(colEntry), getUnicode(colEntry))))
|
maxLen = max(getConsoleLength(column), getConsoleLength(DUMP_REPLACEMENTS.get(getUnicode(colEntry), getUnicode(colEntry))))
|
||||||
|
|
||||||
if maxLen > kb.data.dumpedTable[column]["length"]:
|
if maxLen > kb.data.dumpedTable[column]["length"]:
|
||||||
kb.data.dumpedTable[column]["length"] = maxLen
|
kb.data.dumpedTable[column]["length"] = maxLen
|
||||||
|
|
Loading…
Reference in New Issue
Block a user