From c55ff0e66046b937b26a34f3420d8952c4c1dc34 Mon Sep 17 00:00:00 2001 From: Barisa Obradovic Date: Wed, 29 Mar 2017 22:43:51 +0100 Subject: [PATCH] Hound CI fixes --- nipap-www/nipapwww/controllers/xhr.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/nipap-www/nipapwww/controllers/xhr.py b/nipap-www/nipapwww/controllers/xhr.py index 9c62b4d66..2073a3e9f 100644 --- a/nipap-www/nipapwww/controllers/xhr.py +++ b/nipap-www/nipapwww/controllers/xhr.py @@ -1,5 +1,5 @@ import logging -import urllib +import cgi try: import json except ImportError: @@ -13,11 +13,11 @@ log = logging.getLogger(__name__) -import cgi def html_sanitize(value): if isinstance(value, dict): - value = {html_sanitize(k):html_sanitize(v) for k, v in value.iteritems()} + value = {html_sanitize(k): html_sanitize(v) for + k, v in value.iteritems()} elif isinstance(value, list): value = [html_sanitize(v) for v in value] elif isinstance(value, tuple): @@ -26,12 +26,14 @@ def html_sanitize(value): value = cgi.escape(value, quote=True) return value + def html_sanitize_json(value): ''' Read object, escape all dangerous values and return as json ''' - #First generate json, using nipap encoding library - # We can't sanitize passed value since html_sanitize works on primitive values + # First generate json, using nipap encoding library + # We can't sanitize passed value since html_sanitize works + # on primitive values # while NipapJSONEncoder knows how to decode complex object value_as_json = json.dumps(value, cls=NipapJSONEncoder) # Read back to dictionary, and html sanitize