first round of input sanitization

This commit is contained in:
j 2012-02-21 21:56:06 +05:30
commit 67bc4475e9
7 changed files with 44 additions and 28 deletions

View file

@ -1,18 +1,12 @@
# -*- coding: utf-8 -*-
# ci:si:et:sw=4:sts=4:ts=4
import re
import ox
import html5lib
def cleanup_value(value, layer_type):
#FIXME: what about other types? location etc
if layer_type == 'text':
value = sanitize_fragment(value)
value = ox.parse_html(value)
else:
value = ox.stripTags(value)
value = ox.escape_html(value)
return value
def sanitize_fragment(html):
return html5lib.parseFragment(html).toxml().decode('utf-8')