More replacements from open() to codecs.open(). conf.dataEncoding has to be used only for non-binary files.

This commit is contained in:
Bernardo Damele
2010-05-29 10:10:28 +00:00
parent 84778f0e6c
commit 89c721a451
7 changed files with 35 additions and 19 deletions

View File

@@ -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 ntpath
import os
@@ -150,7 +151,7 @@ class Filesystem(GenericFilesystem):
dFile = posixToNtSlashes(dFile)
dFileName = ntpath.basename(dFile)
wFileSize = os.path.getsize(wFile)
wFilePointer = open(wFile, "rb")
wFilePointer = codecs.open(wFile, "rb")
wFileContent = wFilePointer.read()
wFilePointer.close()

View File

@@ -23,6 +23,7 @@ Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
import binascii
import codecs
import os
from lib.core.agent import agent
@@ -163,8 +164,8 @@ class Filesystem:
"""
fcEncodedList = []
fp = open(fileName, "rb")
fcEncodedStr = fp.read().encode(encoding).replace("\n", "")
fp = codecs.open(fileName, "rb")
fcEncodedStr = fp.read().encode(encoding).replace("\n", "")
if not single:
fcLength = len(fcEncodedStr)