first round of input sanitization
This commit is contained in:
parent
b62b58a967
commit
67bc4475e9
7 changed files with 44 additions and 28 deletions
|
|
@ -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')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue