mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 08:11:00 +00:00
always read files in binary mode
This commit is contained in:
parent
9e7f08acea
commit
0382b809ea
@ -181,7 +181,7 @@ class RandomGenerator:
|
||||
class FileGenerator:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
self.fp = file(path, "r")
|
||||
self.fp = file(path, "rb")
|
||||
self.map = mmap.mmap(self.fp.fileno(), 0, prot=mmap.PROT_READ)
|
||||
|
||||
def __len__(self):
|
||||
@ -957,7 +957,7 @@ def read_file(settings, s):
|
||||
raise FileAccessDenied("File access outside of configured directory")
|
||||
if not os.path.isfile(s):
|
||||
raise FileAccessDenied("File not readable")
|
||||
return file(s, "r").read()
|
||||
return file(s, "rb").read()
|
||||
|
||||
|
||||
def parse_response(settings, s):
|
||||
|
@ -95,7 +95,7 @@ class TestValueFile:
|
||||
v = language.Value.parseString("<path")[0]
|
||||
with tutils.tmpdir() as t:
|
||||
p = os.path.join(t, "path")
|
||||
f = open(p, "w")
|
||||
f = open(p, "wb")
|
||||
f.write("x"*10000)
|
||||
f.close()
|
||||
|
||||
@ -143,7 +143,7 @@ class TestMisc:
|
||||
def test_filegenerator(self):
|
||||
with tutils.tmpdir() as t:
|
||||
path = os.path.join(t, "foo")
|
||||
f = open(path, "w")
|
||||
f = open(path, "wb")
|
||||
f.write("x"*10000)
|
||||
f.close()
|
||||
g = language.FileGenerator(path)
|
||||
|
Loading…
Reference in New Issue
Block a user