mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 01:26:42 +03:00
more dump/unicode cleanup
This commit is contained in:
parent
64ad3b03be
commit
2fb8bf3b6a
|
@ -1352,6 +1352,12 @@ def getCommonStart(strings=[]):
|
|||
|
||||
return retVal
|
||||
|
||||
def getUnicode(value):
|
||||
if isinstance(value, basestring):
|
||||
return value if isinstance(value, unicode) else unicode(value, conf.dataEncoding)
|
||||
else:
|
||||
return unicode(value)
|
||||
|
||||
def getBruteUnicode(string):
|
||||
retVal = unicode()
|
||||
for char in string:
|
||||
|
|
|
@ -27,6 +27,7 @@ import re
|
|||
import os
|
||||
|
||||
from lib.core.common import dataToDumpFile
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import logger
|
||||
|
||||
|
@ -54,7 +55,7 @@ class Dump:
|
|||
conf.loggedToOut = True
|
||||
|
||||
def __formatString(self, string):
|
||||
string = unicode(string)
|
||||
string = getUnicode(string)
|
||||
string = string.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
|
||||
string = string.replace("__START__", "").replace("__STOP__", "")
|
||||
string = string.replace("__DEL__", ", ")
|
||||
|
@ -71,7 +72,7 @@ class Dump:
|
|||
|
||||
return
|
||||
|
||||
data = unicode(data)
|
||||
data = getUnicode(data)
|
||||
|
||||
if data:
|
||||
data = self.__formatString(data)
|
||||
|
@ -99,7 +100,7 @@ class Dump:
|
|||
if isinstance(element, basestring):
|
||||
self.__write("[*] %s" % element)
|
||||
elif isinstance(element, (list, tuple, set)):
|
||||
self.__write("[*] " + ", ".join(unicode(e) for e in element))
|
||||
self.__write("[*] " + ", ".join(getUnicode(e) for e in element))
|
||||
|
||||
if elements:
|
||||
self.__write("")
|
||||
|
@ -318,7 +319,7 @@ class Dump:
|
|||
if column != "__infos__":
|
||||
info = tableValues[column]
|
||||
|
||||
value = unicode(info["values"][i]) if type(info["values"][i]) != unicode else info["values"][i]
|
||||
value = getUnicode(info["values"][i])
|
||||
|
||||
if re.search("^[\ *]*$", value):
|
||||
value = "NULL"
|
||||
|
|
|
@ -7,6 +7,7 @@ import re
|
|||
import xml.sax.saxutils as saxutils
|
||||
from xml.dom.minidom import Document
|
||||
|
||||
from lib.core.common import getUnicode
|
||||
from lib.core.data import conf
|
||||
from lib.core.data import logger
|
||||
from lib.core.exception import sqlmapFilePathException
|
||||
|
@ -130,22 +131,16 @@ class XMLDump:
|
|||
if attrValue is None :
|
||||
attr.nodeValue = u''
|
||||
else :
|
||||
attr.nodeValue = self.__getUnicode(attrValue)
|
||||
attr.nodeValue = getUnicode(attrValue)
|
||||
return attr
|
||||
|
||||
def __formatString(self, string):
|
||||
string = self.__getUnicode(string)
|
||||
string = getUnicode(string)
|
||||
string = string.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
|
||||
string = string.replace("__START__", "").replace("__STOP__", "")
|
||||
string = string.replace("__DEL__", ", ")
|
||||
return string
|
||||
|
||||
def __getUnicode(self, value):
|
||||
if isinstance(value, basestring):
|
||||
return value if isinstance(value, unicode) else unicode(value, "utf-8")
|
||||
else:
|
||||
return unicode(value)
|
||||
|
||||
def string(self, header, data, sort=True):
|
||||
'''
|
||||
Adds string element to the xml.
|
||||
|
@ -196,7 +191,7 @@ class XMLDump:
|
|||
for e in element :
|
||||
memberElemStr = self.__doc.createElement(MEMBER_ELEM)
|
||||
memberElemStr.setAttributeNode(self.__createAttribute(TYPE_ATTR, "string"))
|
||||
memberElemStr.appendChild(self.__createTextNode(self.__getUnicode(e)))
|
||||
memberElemStr.appendChild(self.__createTextNode(getUnicode(e)))
|
||||
memberElem.appendChild(memberElemStr)
|
||||
listsElem = self.__getRootChild(LSTS_ELEM_NAME)
|
||||
if not(listsElem):
|
||||
|
@ -250,7 +245,7 @@ class XMLDump:
|
|||
Adds information to the xml that indicates whether the user has DBA privileges
|
||||
'''
|
||||
isDBAElem = self.__doc.createElement(IS_DBA_ELEM_NAME)
|
||||
isDBAElem.setAttributeNode(self.__createAttribute(VALUE_ATTR, self.__getUnicode(isDBA)))
|
||||
isDBAElem.setAttributeNode(self.__createAttribute(VALUE_ATTR, getUnicode(isDBA)))
|
||||
self.__addToRoot(isDBAElem)
|
||||
|
||||
def users(self,users):
|
||||
|
@ -502,7 +497,7 @@ class XMLDump:
|
|||
'''
|
||||
if ((self.__outputFP is not None) and not(self.__outputFP.closed)):
|
||||
statusElem = self.__doc.createElement(STATUS_ELEM_NAME)
|
||||
statusElem.setAttributeNode(self.__createAttribute(SUCESS_ATTR,self.__getUnicode(resultStatus)))
|
||||
statusElem.setAttributeNode(self.__createAttribute(SUCESS_ATTR,getUnicode(resultStatus)))
|
||||
|
||||
if not(resultStatus) :
|
||||
errorElem = self.__doc.createElement(ERROR_ELEM_NAME)
|
||||
|
@ -510,13 +505,13 @@ class XMLDump:
|
|||
if (isinstance(resultMsg, Exception)):
|
||||
errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, type(resultMsg).__name__))
|
||||
else :
|
||||
errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNHANDLED_PROBLEM_TYPE))
|
||||
errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNHANDLED_PROBLEM_TYPE))
|
||||
|
||||
errorElem.appendChild(self.__createTextNode(self.__getUnicode(resultMsg)))
|
||||
errorElem.appendChild(self.__createTextNode(getUnicode(resultMsg)))
|
||||
statusElem.appendChild(errorElem)
|
||||
|
||||
self.__addToRoot(statusElem)
|
||||
self.__write(self.__doc.toprettyxml(encoding=ENCODING))
|
||||
self.__write(self.__doc.toprettyxml(encoding=ENCODING))
|
||||
self.__outputFP.close()
|
||||
|
||||
def closeDumper(status, msg=""):
|
||||
|
|
Loading…
Reference in New Issue
Block a user