sanitze fallback
This commit is contained in:
parent
f26ddd3a41
commit
9c02e2913e
|
@ -21,7 +21,11 @@ import lxml.html
|
|||
# Create your models here.
|
||||
|
||||
def sanitize_html(string):
|
||||
return '\n'.join(lxml.html.tostring(x) for x in lxml.html.fragment_fromstring(string).iterchildren())
|
||||
try:
|
||||
html = '\n'.join(lxml.html.tostring(x) for x in lxml.html.fragment_fromstring(string).iterchildren())
|
||||
except:
|
||||
html = ox.strip_tags(string.replace('<br>', '\n')).replace('\n\n', '\n').replace('\n', '<br>')
|
||||
return html
|
||||
|
||||
class Acrolike(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
|
|
Loading…
Reference in New Issue
Block a user