mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-29 13:03:50 +03:00
added reusage of xml output and removed toprettyxml which has lots and lots of problems (output once stored is not usable any more from any xml parser/reader because it adds whitespaces all over the output just to be more 'human' readable)
This commit is contained in:
parent
080c71b903
commit
464f171a8c
|
@ -1,10 +1,14 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import codecs
|
import codecs
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
import xml
|
||||||
|
|
||||||
import xml.sax.saxutils as saxutils
|
import xml.sax.saxutils as saxutils
|
||||||
|
|
||||||
from xml.dom.minidom import Document
|
from xml.dom.minidom import Document
|
||||||
|
from xml.parsers.expat import ExpatError
|
||||||
|
|
||||||
from lib.core.common import getUnicode
|
from lib.core.common import getUnicode
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
|
@ -478,7 +482,18 @@ class XMLDump:
|
||||||
if (conf.xmlFile) :
|
if (conf.xmlFile) :
|
||||||
try :
|
try :
|
||||||
self.__outputFile = conf.xmlFile
|
self.__outputFile = conf.xmlFile
|
||||||
self.__outputFP = codecs.open(self.__outputFile, "a", conf.dataEncoding)
|
self.__root = None
|
||||||
|
|
||||||
|
if os.path.exists(self.__outputFile):
|
||||||
|
try:
|
||||||
|
self.__doc = xml.dom.minidom.parse(self.__outputFile)
|
||||||
|
self.__root = self.__doc.childNodes[0]
|
||||||
|
except ExpatError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.__outputFP = codecs.open(self.__outputFile, "w+", conf.dataEncoding)
|
||||||
|
|
||||||
|
if self.__root is None:
|
||||||
self.__root = self.__doc.createElementNS(NAME_SPACE_ATTR, RESULTS_ELEM_NAME)
|
self.__root = self.__doc.createElementNS(NAME_SPACE_ATTR, RESULTS_ELEM_NAME)
|
||||||
self.__root.setAttributeNode(self.__createAttribute(XMLNS_ATTR,NAME_SPACE_ATTR))
|
self.__root.setAttributeNode(self.__createAttribute(XMLNS_ATTR,NAME_SPACE_ATTR))
|
||||||
self.__root.setAttributeNode(self.__createAttribute(SCHEME_NAME_ATTR,SCHEME_NAME))
|
self.__root.setAttributeNode(self.__createAttribute(SCHEME_NAME_ATTR,SCHEME_NAME))
|
||||||
|
@ -509,7 +524,8 @@ class XMLDump:
|
||||||
statusElem.appendChild(errorElem)
|
statusElem.appendChild(errorElem)
|
||||||
|
|
||||||
self.__addToRoot(statusElem)
|
self.__addToRoot(statusElem)
|
||||||
self.__write(self.__doc.toprettyxml(encoding=conf.dataEncoding))
|
#self.__write(self.__doc.toprettyxml(encoding=conf.dataEncoding)) ##don't use toprettyxml, lots of bugs with it
|
||||||
|
self.__write(self.__doc.toxml(encoding=conf.dataEncoding)) ##not human readable, but at least without bugs
|
||||||
self.__outputFP.close()
|
self.__outputFP.close()
|
||||||
|
|
||||||
def closeDumper(status, msg=""):
|
def closeDumper(status, msg=""):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user