aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
authorManish Kumar <mkagenius@gmail.com>2016-08-26 12:52:51 +0530
committerManish Kumar <mkagenius@gmail.com>2016-08-26 12:52:51 +0530
commit16401d5be8fba35599caedb4c78901d4b66ac082 (patch)
treef63b252072105b15f578c86eb6029acd41496d74 /netlib
parent51771c01c61259d8cc62ff8cc9715dced9806354 (diff)
downloadmitmproxy-16401d5be8fba35599caedb4c78901d4b66ac082.tar.gz
mitmproxy-16401d5be8fba35599caedb4c78901d4b66ac082.tar.bz2
mitmproxy-16401d5be8fba35599caedb4c78901d4b66ac082.zip
fixed : Divide by zero error came when string was empty, also a test
Diffstat (limited to 'netlib')
-rw-r--r--netlib/strutils.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/netlib/strutils.py b/netlib/strutils.py
index 4a46b6b1..4cb3b805 100644
--- a/netlib/strutils.py
+++ b/netlib/strutils.py
@@ -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])