Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
binwalk
Commits
4f89d514
Commit
4f89d514
authored
9 years ago
by
Craig Heffner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed codecs encoding
parent
26e2c4d6
master
…
v2.3.4
v2.3.3
v2.3.2
v2.3.1
v2.3.0
v2.2.0
v2.1.1
python27
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
8 deletions
+3
-8
magic.py
src/binwalk/core/magic.py
+2
-6
extractor.py
src/binwalk/modules/extractor.py
+1
-2
No files found.
src/binwalk/core/magic.py
View file @
4f89d514
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
__all__
=
[
'Magic'
]
__all__
=
[
'Magic'
]
import
codecs
import
re
import
re
import
struct
import
struct
import
datetime
import
datetime
...
@@ -790,9 +789,8 @@ class Magic(object):
...
@@ -790,9 +789,8 @@ class Magic(object):
Returns None.
Returns None.
'''
'''
# Open file as UTF-8 to prevent decoding issues for non-ASCII bytes
# Magic files must be ASCII, else encoding issues can arise.
# that may inadvertantly be in the signature file.
fp
=
open
(
fname
,
"r"
)
fp
=
codecs
.
open
(
fname
,
"r"
,
encoding
=
'utf-8'
)
lines
=
fp
.
readlines
()
lines
=
fp
.
readlines
()
self
.
parse
(
lines
)
self
.
parse
(
lines
)
fp
.
close
()
fp
.
close
()
...
@@ -808,8 +806,6 @@ class Magic(object):
...
@@ -808,8 +806,6 @@ class Magic(object):
signature
=
None
signature
=
None
for
line
in
lines
:
for
line
in
lines
:
# The signature lines were read in as UTF-8 unicode; be sure to treat them as strings.
line
=
str
(
line
)
# Split at the first comment delimiter (if any) and strip the result
# Split at the first comment delimiter (if any) and strip the result
line
=
line
.
split
(
'#'
)[
0
]
.
strip
()
line
=
line
.
split
(
'#'
)[
0
]
.
strip
()
# Ignore blank lines and lines that are nothing but comments.
# Ignore blank lines and lines that are nothing but comments.
...
...
This diff is collapsed.
Click to expand it.
src/binwalk/modules/extractor.py
View file @
4f89d514
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
# This is automatically invoked by core.module code if extraction has been
# This is automatically invoked by core.module code if extraction has been
# enabled by the user; other modules need not reference this module directly.
# enabled by the user; other modules need not reference this module directly.
import
codecs
import
os
import
os
import
re
import
re
import
sys
import
sys
...
@@ -318,7 +317,7 @@ class Extractor(Module):
...
@@ -318,7 +317,7 @@ class Extractor(Module):
'''
'''
try
:
try
:
# Process each line from the extract file, ignoring comments
# Process each line from the extract file, ignoring comments
with
codecs
.
open
(
fname
,
'r'
,
encoding
=
'utf-8
'
)
as
f
:
with
open
(
fname
,
'r
'
)
as
f
:
for
rule
in
f
.
readlines
():
for
rule
in
f
.
readlines
():
self
.
add_rule
(
rule
.
split
(
self
.
COMMENT_DELIM
,
1
)[
0
])
self
.
add_rule
(
rule
.
split
(
self
.
COMMENT_DELIM
,
1
)[
0
])
except
KeyboardInterrupt
as
e
:
except
KeyboardInterrupt
as
e
:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment