diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-04-08 14:40:59 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-04-08 14:40:59 +1200 |
commit | 7d90eb65edf58815296f41931dba38d3051a41d7 (patch) | |
tree | 5473c23169c27e8d7a428b513e62ca6816961c8a | |
parent | a4f7728fadd85ba1da92e6c920256b2b4ba8cf0d (diff) | |
download | mitmproxy-7d90eb65edf58815296f41931dba38d3051a41d7.tar.gz mitmproxy-7d90eb65edf58815296f41931dba38d3051a41d7.tar.bz2 mitmproxy-7d90eb65edf58815296f41931dba38d3051a41d7.zip |
Catch all errors when using jsbeautifier.
Turns out there are some problems that can raise arbitrary exceptions.
-rw-r--r-- | libmproxy/console/contentview.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libmproxy/console/contentview.py b/libmproxy/console/contentview.py index 97d217f2..c4e5d9ac 100644 --- a/libmproxy/console/contentview.py +++ b/libmproxy/console/contentview.py @@ -232,7 +232,11 @@ def view_urlencoded(hdrs, content): def view_javascript(hdrs, content): opts = jsbeautifier.default_options() opts.indent_size = 2 - res = jsbeautifier.beautify(content[:VIEW_CUTOFF], opts) + try: + res = jsbeautifier.beautify(content[:VIEW_CUTOFF], opts) + except: + # Bugs in jsbeautifier mean that it can trhow arbitrary errors. + return None return "JavaScript", _view_text(res, len(content)) |