mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-29 21:13:51 +03:00
fixing unicode mess
This commit is contained in:
parent
4d6d5c8447
commit
32a0ba9296
|
@ -116,11 +116,10 @@ class XMLDump:
|
||||||
The text is escaped to an fit the xml text format.
|
The text is escaped to an fit the xml text format.
|
||||||
'''
|
'''
|
||||||
if data is None :
|
if data is None :
|
||||||
return self.__doc.createTextNode(unicode("","utf-8"))
|
return self.__doc.createTextNode('')
|
||||||
else :
|
else :
|
||||||
string = self.__formatString(data)
|
escaped_data = saxutils.escape(self.__formatString(data), ENTITIES)
|
||||||
escaped_data = saxutils.escape(unicode(string), ENTITIES)
|
return self.__doc.createTextNode(escaped_data)
|
||||||
return self.__doc.createTextNode(unicode(escaped_data, "utf-8"))
|
|
||||||
|
|
||||||
def __createAttribute(self,attrName,attrValue):
|
def __createAttribute(self,attrName,attrValue):
|
||||||
'''
|
'''
|
||||||
|
@ -129,18 +128,24 @@ class XMLDump:
|
||||||
'''
|
'''
|
||||||
attr = self.__doc.createAttribute(attrName)
|
attr = self.__doc.createAttribute(attrName)
|
||||||
if attrValue is None :
|
if attrValue is None :
|
||||||
attr.nodeValue = unicode("","utf-8")
|
attr.nodeValue = ''
|
||||||
else :
|
else :
|
||||||
attr.nodeValue = attrValue if isinstance(attrValue, unicode) else unicode(attrValue,"utf-8")
|
attr.nodeValue = self.__getUnicode(attrValue)
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
def __formatString(self, string):
|
def __formatString(self, string):
|
||||||
string = unicode(string)
|
string = self.__getUnicode(string)
|
||||||
string = string.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
|
string = string.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
|
||||||
string = string.replace("__START__", "").replace("__STOP__", "")
|
string = string.replace("__START__", "").replace("__STOP__", "")
|
||||||
string = string.replace("__DEL__", ", ")
|
string = string.replace("__DEL__", ", ")
|
||||||
return string
|
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):
|
def string(self, header, data, sort=True):
|
||||||
'''
|
'''
|
||||||
Adds string element to the xml.
|
Adds string element to the xml.
|
||||||
|
@ -191,7 +196,7 @@ class XMLDump:
|
||||||
for e in element :
|
for e in element :
|
||||||
memberElemStr = self.__doc.createElement(MEMBER_ELEM)
|
memberElemStr = self.__doc.createElement(MEMBER_ELEM)
|
||||||
memberElemStr.setAttributeNode(self.__createAttribute(TYPE_ATTR, "string"))
|
memberElemStr.setAttributeNode(self.__createAttribute(TYPE_ATTR, "string"))
|
||||||
memberElemStr.appendChild(self.__createTextNode(unicode(e)))
|
memberElemStr.appendChild(self.__createTextNode(self.__getUnicode(e)))
|
||||||
memberElem.appendChild(memberElemStr)
|
memberElem.appendChild(memberElemStr)
|
||||||
listsElem = self.__getRootChild(LSTS_ELEM_NAME)
|
listsElem = self.__getRootChild(LSTS_ELEM_NAME)
|
||||||
if not(listsElem):
|
if not(listsElem):
|
||||||
|
@ -245,7 +250,7 @@ class XMLDump:
|
||||||
Adds information to the xml that indicates whether the user has DBA privileges
|
Adds information to the xml that indicates whether the user has DBA privileges
|
||||||
'''
|
'''
|
||||||
isDBAElem = self.__doc.createElement(IS_DBA_ELEM_NAME)
|
isDBAElem = self.__doc.createElement(IS_DBA_ELEM_NAME)
|
||||||
isDBAElem.setAttributeNode(self.__createAttribute(VALUE_ATTR, unicode(isDBA)))
|
isDBAElem.setAttributeNode(self.__createAttribute(VALUE_ATTR, self.__getUnicode(isDBA)))
|
||||||
self.__addToRoot(isDBAElem)
|
self.__addToRoot(isDBAElem)
|
||||||
|
|
||||||
def users(self,users):
|
def users(self,users):
|
||||||
|
@ -497,7 +502,7 @@ class XMLDump:
|
||||||
'''
|
'''
|
||||||
if ((self.__outputFP is not None) and not(self.__outputFP.closed)):
|
if ((self.__outputFP is not None) and not(self.__outputFP.closed)):
|
||||||
statusElem = self.__doc.createElement(STATUS_ELEM_NAME)
|
statusElem = self.__doc.createElement(STATUS_ELEM_NAME)
|
||||||
statusElem.setAttributeNode(self.__createAttribute(SUCESS_ATTR,unicode(resultStatus)))
|
statusElem.setAttributeNode(self.__createAttribute(SUCESS_ATTR,self.__getUnicode(resultStatus)))
|
||||||
|
|
||||||
if not(resultStatus) :
|
if not(resultStatus) :
|
||||||
errorElem = self.__doc.createElement(ERROR_ELEM_NAME)
|
errorElem = self.__doc.createElement(ERROR_ELEM_NAME)
|
||||||
|
@ -507,7 +512,7 @@ class XMLDump:
|
||||||
else :
|
else :
|
||||||
errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNHANDLED_PROBLEM_TYPE))
|
errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNHANDLED_PROBLEM_TYPE))
|
||||||
|
|
||||||
errorElem.appendChild(self.__createTextNode(unicode(resultMsg)))
|
errorElem.appendChild(self.__createTextNode(self.__getUnicode(resultMsg)))
|
||||||
statusElem.appendChild(errorElem)
|
statusElem.appendChild(errorElem)
|
||||||
|
|
||||||
self.__addToRoot(statusElem)
|
self.__addToRoot(statusElem)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user