mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-08 21:51:29 +00:00
More replacements from open() to codecs.open(). conf.dataEncoding has to be used only for non-binary files.
This commit is contained in:
@@ -1080,8 +1080,10 @@ def decloakToNamedTemporaryFile(filepath, name=None):
|
||||
def decloakToMkstemp(filepath, **kwargs):
|
||||
name = mkstemp(**kwargs)[1]
|
||||
retVal = open(name, 'w+b')
|
||||
|
||||
retVal.write(decloak(filepath))
|
||||
retVal.seek(0)
|
||||
|
||||
return retVal
|
||||
|
||||
def isWindowsPath(filepath):
|
||||
@@ -1143,7 +1145,7 @@ def profile(profileOutputFile=None, dotOutputFile=None, imageOutputFile=None):
|
||||
|
||||
# Create dot file by using extra/gprof2dot/gprof2dot.py
|
||||
# http://code.google.com/p/jrfonseca/wiki/Gprof2Dot
|
||||
dotFilePointer = open(dotOutputFile, 'wt')
|
||||
dotFilePointer = codecs.open(dotOutputFile, 'wt', conf.dataEncoding)
|
||||
parser = gprof2dot.PstatsParser(profileOutputFile)
|
||||
profile = parser.parse()
|
||||
profile.prune(0.5/100.0, 0.1/100.0)
|
||||
@@ -1194,7 +1196,7 @@ def getConsoleWidth(default=80):
|
||||
return width if width else default
|
||||
|
||||
def parseXmlFile(xmlFile, handler):
|
||||
xfile = open(xmlFile)
|
||||
xfile = codecs.open(xmlFile, 'rb', conf.dataEncoding)
|
||||
content = xfile.read()
|
||||
stream = StringIO(content)
|
||||
parse(stream, handler)
|
||||
@@ -1209,7 +1211,7 @@ def initCommonOutputs():
|
||||
key = None
|
||||
|
||||
fileName = os.path.join(paths.SQLMAP_TXT_PATH, 'common-outputs.txt')
|
||||
cfile = open(fileName, 'r')
|
||||
cfile = codecs.open(fileName, 'r', conf.dataEncoding)
|
||||
|
||||
for line in cfile.xreadlines():
|
||||
line = line.strip()
|
||||
|
||||
@@ -96,7 +96,7 @@ def __urllib2Opener():
|
||||
urllib2.install_opener(opener)
|
||||
|
||||
def __feedTargetsDict(reqFile, addedTargetUrls):
|
||||
fp = codecs.open(reqFile, "rb", conf.dataEncoding)
|
||||
fp = codecs.open(reqFile, "rb")
|
||||
|
||||
fread = fp.read()
|
||||
fread = fread.replace("\r", "")
|
||||
@@ -745,7 +745,7 @@ def __setHTTPUserAgent():
|
||||
logger.debug(debugMsg)
|
||||
|
||||
try:
|
||||
fd = open(conf.userAgentsFile, "r")
|
||||
fd = codecs.open(conf.userAgentsFile, "r", conf.dataEncoding)
|
||||
except IOError:
|
||||
warnMsg = "unable to read HTTP User-Agent header "
|
||||
warnMsg += "file '%s'" % conf.userAgentsFile
|
||||
|
||||
@@ -22,6 +22,7 @@ with sqlmap; if not, write to the Free Software Foundation, Inc., 51
|
||||
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
"""
|
||||
|
||||
import codecs
|
||||
import difflib
|
||||
import os
|
||||
import re
|
||||
@@ -145,7 +146,7 @@ def __updateMSSQLXML():
|
||||
servicepackElement.appendChild(servicepackText)
|
||||
|
||||
# Get the XML old file content to a local variable
|
||||
mssqlXml = open(paths.MSSQL_XML, "r")
|
||||
mssqlXml = codecs.open(paths.MSSQL_XML, "r", conf.dataEncoding)
|
||||
oldMssqlXml = mssqlXml.read()
|
||||
oldMssqlXmlSignatures = oldMssqlXml.count("<signature>")
|
||||
oldMssqlXmlList = oldMssqlXml.splitlines(1)
|
||||
@@ -155,12 +156,12 @@ def __updateMSSQLXML():
|
||||
shutil.copy(paths.MSSQL_XML, "%s.bak" % paths.MSSQL_XML)
|
||||
|
||||
# Save our newly created XML to the signatures file
|
||||
mssqlXml = open(paths.MSSQL_XML, "w")
|
||||
mssqlXml = codecs.open(paths.MSSQL_XML, "w", conf.dataEncoding)
|
||||
doc.writexml(writer=mssqlXml, addindent=" ", newl="\n")
|
||||
mssqlXml.close()
|
||||
|
||||
# Get the XML new file content to a local variable
|
||||
mssqlXml = open(paths.MSSQL_XML, "r")
|
||||
mssqlXml = codecs.open(paths.MSSQL_XML, "r", conf.dataEncoding)
|
||||
newMssqlXml = mssqlXml.read()
|
||||
newMssqlXmlSignatures = newMssqlXml.count("<signature>")
|
||||
newMssqlXmlList = newMssqlXml.splitlines(1)
|
||||
|
||||
Reference in New Issue
Block a user