Skip to content

Commit

Permalink
Hound CI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaja42 committed Mar 29, 2017
1 parent 412a191 commit c55ff0e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions nipap-www/nipapwww/controllers/xhr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
import urllib
import cgi
try:
import json
except ImportError:
Expand All @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit c55ff0e

Please sign in to comment.