Catch all errors when using jsbeautifier.

Turns out there are some problems that can raise arbitrary exceptions.
This commit is contained in:
Aldo Cortesi 2012-04-08 14:40:59 +12:00
parent a4f7728fad
commit 7d90eb65ed

View File

@ -232,7 +232,11 @@ def view_urlencoded(hdrs, content):
def view_javascript(hdrs, content):
opts = jsbeautifier.default_options()
opts.indent_size = 2
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))