Improve signature/vacation file handling

Strip BOM_UTF8 from encoded data read by readFile; Windows puts a
BOM_UTF8 in UTF-8 files.
This commit is contained in:
Ross Scroggs
2016-03-19 10:34:49 -07:00
parent 087c6775e3
commit fb9aebf123

View File

@@ -402,7 +402,10 @@ def readFile(filename, mode=u'rb', continueOnError=False, displayError=True, enc
return f.read()
else:
with codecs.open(filename, mode, encoding) as f:
return f.read()
content = f.read()
if not content.startswith(codecs.BOM_UTF8):
return content
return content.replace(codecs.BOM_UTF8, u'', 1)
else:
return unicode(sys.stdin.read())
except IOError as e: