diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-09-12 17:57:21 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-09-12 17:57:21 +0200 |
commit | 32b487109f2d555870a0e93026968fa6eacf9f11 (patch) | |
tree | 6aab46bceebb0520bd8f31fe7535ab4d0cadf170 /libmproxy/utils.py | |
parent | 4106e1961246616a33c6a1b9d7b8208000611e3d (diff) | |
parent | 5fe12a467f37bfba2f4f663274cacbc6ecc770f7 (diff) | |
download | mitmproxy-32b487109f2d555870a0e93026968fa6eacf9f11.tar.gz mitmproxy-32b487109f2d555870a0e93026968fa6eacf9f11.tar.bz2 mitmproxy-32b487109f2d555870a0e93026968fa6eacf9f11.zip |
Merge pull request #765 from mitmproxy/such-colors-very-wow
Improve Content Views
Diffstat (limited to 'libmproxy/utils.py')
-rw-r--r-- | libmproxy/utils.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libmproxy/utils.py b/libmproxy/utils.py index 4b591250..8bd843a0 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import (absolute_import, print_function, division) import os import datetime import re @@ -30,15 +30,16 @@ def isBin(s): """ for i in s: i = ord(i) - if i < 9: - return True - elif i > 13 and i < 32: - return True - elif i > 126: + if i < 9 or 13 < i < 32 or 126 < i: return True return False +def isMostlyBin(s): + s = s[:100] + return sum(isBin(ch) for ch in s)/len(s) > 0.3 + + def isXML(s): for i in s: if i in "\n \t": |