|
7 | 7 | import xml.sax.saxutils as saxutils |
8 | 8 | from xml.dom.minidom import Document |
9 | 9 |
|
| 10 | +from lib.core.common import getUnicode |
10 | 11 | from lib.core.data import conf |
11 | 12 | from lib.core.data import logger |
12 | 13 | from lib.core.exception import sqlmapFilePathException |
@@ -130,22 +131,16 @@ def __createAttribute(self,attrName,attrValue): |
130 | 131 | if attrValue is None : |
131 | 132 | attr.nodeValue = u'' |
132 | 133 | else : |
133 | | - attr.nodeValue = self.__getUnicode(attrValue) |
| 134 | + attr.nodeValue = getUnicode(attrValue) |
134 | 135 | return attr |
135 | 136 |
|
136 | 137 | def __formatString(self, string): |
137 | | - string = self.__getUnicode(string) |
| 138 | + string = getUnicode(string) |
138 | 139 | string = string.replace("__NEWLINE__", "\n").replace("__TAB__", "\t") |
139 | 140 | string = string.replace("__START__", "").replace("__STOP__", "") |
140 | 141 | string = string.replace("__DEL__", ", ") |
141 | 142 | return string |
142 | 143 |
|
143 | | - def __getUnicode(self, value): |
144 | | - if isinstance(value, basestring): |
145 | | - return value if isinstance(value, unicode) else unicode(value, "utf-8") |
146 | | - else: |
147 | | - return unicode(value) |
148 | | - |
149 | 144 | def string(self, header, data, sort=True): |
150 | 145 | ''' |
151 | 146 | Adds string element to the xml. |
@@ -196,7 +191,7 @@ def lister(self, header, elements, sort=True): |
196 | 191 | for e in element : |
197 | 192 | memberElemStr = self.__doc.createElement(MEMBER_ELEM) |
198 | 193 | memberElemStr.setAttributeNode(self.__createAttribute(TYPE_ATTR, "string")) |
199 | | - memberElemStr.appendChild(self.__createTextNode(self.__getUnicode(e))) |
| 194 | + memberElemStr.appendChild(self.__createTextNode(getUnicode(e))) |
200 | 195 | memberElem.appendChild(memberElemStr) |
201 | 196 | listsElem = self.__getRootChild(LSTS_ELEM_NAME) |
202 | 197 | if not(listsElem): |
@@ -250,7 +245,7 @@ def dba(self,isDBA): |
250 | 245 | Adds information to the xml that indicates whether the user has DBA privileges |
251 | 246 | ''' |
252 | 247 | isDBAElem = self.__doc.createElement(IS_DBA_ELEM_NAME) |
253 | | - isDBAElem.setAttributeNode(self.__createAttribute(VALUE_ATTR, self.__getUnicode(isDBA))) |
| 248 | + isDBAElem.setAttributeNode(self.__createAttribute(VALUE_ATTR, getUnicode(isDBA))) |
254 | 249 | self.__addToRoot(isDBAElem) |
255 | 250 |
|
256 | 251 | def users(self,users): |
@@ -502,21 +497,21 @@ def finish(self, resultStatus, resultMsg=""): |
502 | 497 | ''' |
503 | 498 | if ((self.__outputFP is not None) and not(self.__outputFP.closed)): |
504 | 499 | statusElem = self.__doc.createElement(STATUS_ELEM_NAME) |
505 | | - statusElem.setAttributeNode(self.__createAttribute(SUCESS_ATTR,self.__getUnicode(resultStatus))) |
| 500 | + statusElem.setAttributeNode(self.__createAttribute(SUCESS_ATTR,getUnicode(resultStatus))) |
506 | 501 |
|
507 | 502 | if not(resultStatus) : |
508 | 503 | errorElem = self.__doc.createElement(ERROR_ELEM_NAME) |
509 | 504 |
|
510 | 505 | if (isinstance(resultMsg, Exception)): |
511 | 506 | errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, type(resultMsg).__name__)) |
512 | 507 | else : |
513 | | - errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNHANDLED_PROBLEM_TYPE)) |
| 508 | + errorElem.setAttributeNode(self.__createAttribute(TYPE_ATTR, UNHANDLED_PROBLEM_TYPE)) |
514 | 509 |
|
515 | | - errorElem.appendChild(self.__createTextNode(self.__getUnicode(resultMsg))) |
| 510 | + errorElem.appendChild(self.__createTextNode(getUnicode(resultMsg))) |
516 | 511 | statusElem.appendChild(errorElem) |
517 | 512 |
|
518 | 513 | self.__addToRoot(statusElem) |
519 | | - self.__write(self.__doc.toprettyxml(encoding=ENCODING)) |
| 514 | + self.__write(self.__doc.toprettyxml(encoding=ENCODING)) |
520 | 515 | self.__outputFP.close() |
521 | 516 |
|
522 | 517 | def closeDumper(status, msg=""): |
|
0 commit comments