mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-02-02 20:54:13 +03:00
Patch for an Issue #964
This commit is contained in:
parent
40eb1973d7
commit
080a873922
|
@ -1889,31 +1889,36 @@ def getFileItems(filename, commentPrefix='#', unicode_=True, lowercase=False, un
|
||||||
|
|
||||||
checkFile(filename)
|
checkFile(filename)
|
||||||
|
|
||||||
with codecs.open(filename, 'r', UNICODE_ENCODING, errors="ignore") if unicode_ else open(filename, 'r') as f:
|
try:
|
||||||
for line in (f.readlines() if unicode_ else f.xreadlines()): # xreadlines doesn't return unicode strings when codec.open() is used
|
with codecs.open(filename, 'r', UNICODE_ENCODING, errors="ignore") if unicode_ else open(filename, 'r') as f:
|
||||||
if commentPrefix:
|
for line in (f.readlines() if unicode_ else f.xreadlines()): # xreadlines doesn't return unicode strings when codec.open() is used
|
||||||
if line.find(commentPrefix) != -1:
|
if commentPrefix:
|
||||||
line = line[:line.find(commentPrefix)]
|
if line.find(commentPrefix) != -1:
|
||||||
|
line = line[:line.find(commentPrefix)]
|
||||||
|
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
|
||||||
if not unicode_:
|
if not unicode_:
|
||||||
try:
|
try:
|
||||||
line = str.encode(line)
|
line = str.encode(line)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if line:
|
if line:
|
||||||
if lowercase:
|
if lowercase:
|
||||||
line = line.lower()
|
line = line.lower()
|
||||||
|
|
||||||
if unique and line in retVal:
|
if unique and line in retVal:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if unique:
|
if unique:
|
||||||
retVal[line] = True
|
retVal[line] = True
|
||||||
else:
|
else:
|
||||||
retVal.append(line)
|
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()
|
return retVal if not unique else retVal.keys()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user