Patch of potential silent bug (digits charset)

This commit is contained in:
Miroslav Stampar 2017-10-31 10:03:23 +01:00
parent ff5bdbefe8
commit ac2359f8df

View File

@ -1649,11 +1649,11 @@ def getFileType(filePath):
""" """
try: try:
_ = magic.from_file(filePath) desc = magic.from_file(filePath) or ""
except: except:
return "unknown" return "unknown"
return "text" if "ASCII" in _ or "text" in _ else "binary" return "text" if any(_ in desc.lower() for _ in ("ascii", "text")) else "binary"
def getCharset(charsetType=None): def getCharset(charsetType=None):
""" """
@ -1669,14 +1669,14 @@ def getCharset(charsetType=None):
if charsetType is None: if charsetType is None:
asciiTbl.extend(xrange(0, 128)) asciiTbl.extend(xrange(0, 128))
# 0 or 1 # Binary
elif charsetType == CHARSET_TYPE.BINARY: elif charsetType == CHARSET_TYPE.BINARY:
asciiTbl.extend([0, 1]) asciiTbl.extend([0, 1])
asciiTbl.extend(xrange(47, 50)) asciiTbl.extend(xrange(47, 50))
# Digits # Digits
elif charsetType == CHARSET_TYPE.DIGITS: elif charsetType == CHARSET_TYPE.DIGITS:
asciiTbl.extend([0, 1]) asciiTbl.extend([0, 9])
asciiTbl.extend(xrange(47, 58)) asciiTbl.extend(xrange(47, 58))
# Hexadecimal # Hexadecimal