mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-04 01:05:36 +00:00
Merge pull request #1510 from mkagenius/dividebyzero
fixed #1501 : Divide by zero error came when string was empty, also a test
This commit is contained in:
commit
af0a58256a
@ -121,6 +121,9 @@ def escaped_str_to_bytes(data):
|
||||
|
||||
def is_mostly_bin(s):
|
||||
# type: (bytes) -> bool
|
||||
if not s or len(s) == 0:
|
||||
return False
|
||||
|
||||
return sum(
|
||||
i < 9 or 13 < i < 32 or 126 < i
|
||||
for i in six.iterbytes(s[:100])
|
||||
|
@ -85,6 +85,7 @@ def test_escaped_str_to_bytes():
|
||||
def test_is_mostly_bin():
|
||||
assert not strutils.is_mostly_bin(b"foo\xFF")
|
||||
assert strutils.is_mostly_bin(b"foo" + b"\xFF" * 10)
|
||||
assert not strutils.is_mostly_bin("")
|
||||
|
||||
|
||||
def test_is_xml():
|
||||
|
Loading…
Reference in New Issue
Block a user