mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 17:46:37 +03:00
code refactoring regarding issue #184
This commit is contained in:
parent
e9be60e1ac
commit
0197f8db5c
|
@ -356,7 +356,7 @@ def dataToStdout(data):
|
||||||
sys.stdout.write(data)
|
sys.stdout.write(data)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
print data.encode("utf8")
|
print data.encode(conf.dataEncoding)
|
||||||
|
|
||||||
def dataToSessionFile(data):
|
def dataToSessionFile(data):
|
||||||
if not conf.sessionFile:
|
if not conf.sessionFile:
|
||||||
|
@ -375,7 +375,7 @@ def dataToOutFile(data):
|
||||||
|
|
||||||
rFile = filePathToString(conf.rFile)
|
rFile = filePathToString(conf.rFile)
|
||||||
rFilePath = "%s%s%s" % (conf.filePath, os.sep, rFile)
|
rFilePath = "%s%s%s" % (conf.filePath, os.sep, rFile)
|
||||||
rFileFP = codecs.open(rFilePath, "wb", "utf-8")
|
rFileFP = codecs.open(rFilePath, "wb", conf.dataEncoding)
|
||||||
|
|
||||||
rFileFP.write(data)
|
rFileFP.write(data)
|
||||||
rFileFP.flush()
|
rFileFP.flush()
|
||||||
|
@ -416,7 +416,7 @@ def fileToStr(fileName):
|
||||||
@rtype: C{str}
|
@rtype: C{str}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
filePointer = codecs.open(fileName, "r", "utf-8")
|
filePointer = codecs.open(fileName, "r", conf.dataEncoding)
|
||||||
fileText = filePointer.read()
|
fileText = filePointer.read()
|
||||||
|
|
||||||
return fileText.replace(" ", "").replace("\t", "").replace("\r", "").replace("\n", " ")
|
return fileText.replace(" ", "").replace("\t", "").replace("\r", "").replace("\n", " ")
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Dump:
|
||||||
|
|
||||||
def setOutputFile(self):
|
def setOutputFile(self):
|
||||||
self.__outputFile = "%s%slog" % (conf.outputPath, os.sep)
|
self.__outputFile = "%s%slog" % (conf.outputPath, os.sep)
|
||||||
self.__outputFP = codecs.open(self.__outputFile, "a", "utf-8")
|
self.__outputFP = codecs.open(self.__outputFile, "a", conf.dataEncoding)
|
||||||
|
|
||||||
def string(self, header, data, sort=True):
|
def string(self, header, data, sort=True):
|
||||||
if isinstance(data, (list, tuple, set)):
|
if isinstance(data, (list, tuple, set)):
|
||||||
|
@ -268,7 +268,7 @@ class Dump:
|
||||||
os.makedirs(dumpDbPath, 0755)
|
os.makedirs(dumpDbPath, 0755)
|
||||||
|
|
||||||
dumpFileName = "%s%s%s.csv" % (dumpDbPath, os.sep, table)
|
dumpFileName = "%s%s%s.csv" % (dumpDbPath, os.sep, table)
|
||||||
dumpFP = codecs.open(dumpFileName, "w", "utf-8")
|
dumpFP = codecs.open(dumpFileName, "w", conf.dataEncoding)
|
||||||
|
|
||||||
count = int(tableValues["__infos__"]["count"])
|
count = int(tableValues["__infos__"]["count"])
|
||||||
separator = ""
|
separator = ""
|
||||||
|
|
|
@ -97,7 +97,7 @@ def __urllib2Opener():
|
||||||
urllib2.install_opener(opener)
|
urllib2.install_opener(opener)
|
||||||
|
|
||||||
def __feedTargetsDict(reqFile, addedTargetUrls):
|
def __feedTargetsDict(reqFile, addedTargetUrls):
|
||||||
fp = codecs.open(reqFile, "r", "utf-8")
|
fp = codecs.open(reqFile, "r", conf.dataEncoding)
|
||||||
|
|
||||||
fread = fp.read()
|
fread = fp.read()
|
||||||
fread = fread.replace("\r", "")
|
fread = fread.replace("\r", "")
|
||||||
|
@ -884,6 +884,7 @@ def __setConfAttributes():
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
conf.cj = None
|
conf.cj = None
|
||||||
|
conf.dataEncoding = "utf-8"
|
||||||
conf.dbmsConnector = None
|
conf.dbmsConnector = None
|
||||||
conf.dbmsHandler = None
|
conf.dbmsHandler = None
|
||||||
conf.dumpPath = None
|
conf.dumpPath = None
|
||||||
|
|
|
@ -122,7 +122,7 @@ def __setOutputResume():
|
||||||
|
|
||||||
if os.path.exists(conf.sessionFile):
|
if os.path.exists(conf.sessionFile):
|
||||||
if not conf.flushSession:
|
if not conf.flushSession:
|
||||||
readSessionFP = codecs.open(conf.sessionFile, "r", "utf-8")
|
readSessionFP = codecs.open(conf.sessionFile, "r", conf.dataEncoding)
|
||||||
__url_cache = set()
|
__url_cache = set()
|
||||||
__expression_cache = {}
|
__expression_cache = {}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ def __setOutputResume():
|
||||||
raise sqlmapFilePathException, errMsg
|
raise sqlmapFilePathException, errMsg
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conf.sessionFP = codecs.open(conf.sessionFile, "a", "utf-8")
|
conf.sessionFP = codecs.open(conf.sessionFile, "a", conf.dataEncoding)
|
||||||
dataToSessionFile("\n[%s]\n" % time.strftime("%X %x"))
|
dataToSessionFile("\n[%s]\n" % time.strftime("%X %x"))
|
||||||
except IOError:
|
except IOError:
|
||||||
errMsg = "unable to write on the session file specified"
|
errMsg = "unable to write on the session file specified"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user