Commit a14acb7a by devttys0

Merge pull request #167 from bkabrda/master

Make sure binwalk always opens files with utf-8 encoding
parents 12590c75 c5ffe186
# Code to handle displaying and logging of results.
# Anything in binwalk that prints results to screen should use this class.
import codecs
import sys
import codecs
import csv as pycsv
......@@ -30,7 +31,7 @@ class Display(object):
self._configure_formatting()
if log:
self.fp = open(log, "a")
self.fp = codecs.open(log, "a", encoding='utf-8')
if csv:
self.csv = pycsv.writer(self.fp)
......
......@@ -4,6 +4,7 @@
__all__ = ['Magic']
import codecs
import re
import struct
import datetime
......@@ -789,7 +790,7 @@ class Magic(object):
Returns None.
'''
fp = open(fname, "r")
fp = codecs.open(fname, "r", encoding='utf-8')
lines = fp.readlines()
self.parse(lines)
fp.close()
......
......@@ -2,6 +2,7 @@
# This is automatically invoked by core.module code if extraction has been
# enabled by the user; other modules need not reference this module directly.
import codecs
import os
import re
import sys
......@@ -317,7 +318,7 @@ class Extractor(Module):
'''
try:
# Process each line from the extract file, ignoring comments
with open(fname, 'r') as f:
with codecs.open(fname, 'r', encoding='utf-8') as f:
for rule in f.readlines():
self.add_rule(rule.split(self.COMMENT_DELIM, 1)[0])
except KeyboardInterrupt as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment