Patch for an Issue #964

This commit is contained in:
Miroslav Stampar 2014-11-23 15:39:08 +01:00
parent 40eb1973d7
commit 080a873922

View File

@ -1889,6 +1889,7 @@ def getFileItems(filename, commentPrefix='#', unicode_=True, lowercase=False, un
checkFile(filename)
try:
with codecs.open(filename, 'r', UNICODE_ENCODING, errors="ignore") if unicode_ else open(filename, 'r') as f:
for line in (f.readlines() if unicode_ else f.xreadlines()): # xreadlines doesn't return unicode strings when codec.open() is used
if commentPrefix:
@ -1914,6 +1915,10 @@ def getFileItems(filename, commentPrefix='#', unicode_=True, lowercase=False, un
retVal[line] = True
else:
retVal.append(line)
except (IOError, OSError), ex:
errMsg = "something went wrong while trying "
errMsg += "to read the content of file '%s' ('%s')" % (filename, ex)
raise SqlmapGenericException(errMsg)
return retVal if not unique else retVal.keys()