2010-12-29 10:49:34 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# ci:si:et:sw=4:sts=4:ts=4
|
2011-01-01 11:44:42 +00:00
|
|
|
import re
|
|
|
|
import ox
|
2011-12-26 14:30:30 +00:00
|
|
|
import html5lib
|
2011-01-01 11:44:42 +00:00
|
|
|
|
2010-12-29 10:49:34 +00:00
|
|
|
|
2011-12-26 14:30:30 +00:00
|
|
|
def cleanup_value(value, layer_type):
|
|
|
|
#FIXME: what about other types? location etc
|
|
|
|
if layer_type == 'text':
|
|
|
|
value = sanitize_fragment(value)
|
2010-12-29 10:49:34 +00:00
|
|
|
else:
|
2011-12-26 14:30:30 +00:00
|
|
|
value = ox.stripTags(value)
|
|
|
|
return value
|
2011-01-01 11:44:42 +00:00
|
|
|
|
2011-12-26 14:30:30 +00:00
|
|
|
def sanitize_fragment(html):
|
2011-12-26 14:43:04 +00:00
|
|
|
return html5lib.parseFragment(html).toxml().decode('utf-8')
|
2011-01-01 11:44:42 +00:00
|
|
|
|