mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-03-03 11:45:46 +03:00
minor optimization
This commit is contained in:
parent
094129a656
commit
8a7b0406c8
|
@ -24,6 +24,9 @@ HEX_ENCODED_CHAR_REGEX = r"(?P<result>\\x[0-9A-Fa-f]{2})"
|
|||
# Raw chars that will be safe encoded to their slash (\) representations (e.g. newline to \n)
|
||||
SAFE_ENCODE_SLASH_REPLACEMENTS = "\t\n\r\x0b\x0c"
|
||||
|
||||
# Characters that don't need to be safe encoded
|
||||
SAFE_CHARS = "".join(filter(lambda x: x not in SAFE_ENCODE_SLASH_REPLACEMENTS, string.printable.replace('\\', '')))
|
||||
|
||||
# String used for temporary marking of slash characters
|
||||
SLASH_MARKER = "__SLASH__"
|
||||
|
||||
|
@ -40,15 +43,15 @@ def safecharencode(value):
|
|||
retVal = value
|
||||
|
||||
if isinstance(value, basestring):
|
||||
retVal = retVal.replace('\\', SLASH_MARKER)
|
||||
if any(_ not in SAFE_CHARS for _ in value):
|
||||
retVal = retVal.replace('\\', SLASH_MARKER)
|
||||
|
||||
for char in SAFE_ENCODE_SLASH_REPLACEMENTS:
|
||||
retVal = retVal.replace(char, repr(char).strip('\''))
|
||||
for char in SAFE_ENCODE_SLASH_REPLACEMENTS:
|
||||
retVal = retVal.replace(char, repr(char).strip('\''))
|
||||
|
||||
retVal = retVal.replace(SLASH_MARKER, '\\\\')
|
||||
|
||||
retVal = reduce(lambda x, y: x + (y if (y in string.printable or ord(y) > 255) else '\\x%02x' % ord(y)), retVal, unicode())
|
||||
retVal = retVal.replace(SLASH_MARKER, '\\\\')
|
||||
|
||||
retVal = reduce(lambda x, y: x + (y if (y in string.printable or ord(y) > 255) else '\\x%02x' % ord(y)), retVal, unicode())
|
||||
elif isinstance(value, list):
|
||||
for i in xrange(len(value)):
|
||||
retVal[i] = safecharencode(value[i])
|
||||
|
|
|
@ -1332,12 +1332,12 @@ def parseUnionPage(output, unique=True):
|
|||
if output is None:
|
||||
return None
|
||||
|
||||
data = BigArray()
|
||||
|
||||
if output.startswith(kb.chars.start) and output.endswith(kb.chars.stop):
|
||||
data = BigArray()
|
||||
_ = []
|
||||
|
||||
regExpr = '%s(.*?)%s' % (kb.chars.start, kb.chars.stop)
|
||||
output = re.finditer(regExpr, output, re.DOTALL | re.IGNORECASE)
|
||||
_ = []
|
||||
|
||||
for entry in output:
|
||||
entry = entry.group(1)
|
||||
|
|
Loading…
Reference in New Issue
Block a user