plugin XEP_0277: fix encode/decode errors
This commit is contained in:
parent
a3e2beeeae
commit
63bf55d69f
1 changed files with 2 additions and 2 deletions
|
|
@ -218,13 +218,13 @@ class XEP_0277(object):
|
||||||
converted = yield synt.convert(data[attr], synt.getCurrentSyntax(profile), "XHTML")
|
converted = yield synt.convert(data[attr], synt.getCurrentSyntax(profile), "XHTML")
|
||||||
else: # clean the XHTML input
|
else: # clean the XHTML input
|
||||||
converted = yield synt.clean_xhtml(data[attr])
|
converted = yield synt.clean_xhtml(data[attr])
|
||||||
elem = elems[key](u'<div xmlns="%s">%s</div>' % (NS_XHTML, converted))
|
elem = elems[key]((u'<div xmlns="%s">%s</div>' % (NS_XHTML, converted)).encode('utf-8'))
|
||||||
elem.attrs['type'] = 'xhtml'
|
elem.attrs['type'] = 'xhtml'
|
||||||
if hasattr(_entry, '%s_xhtml' % key):
|
if hasattr(_entry, '%s_xhtml' % key):
|
||||||
raise exceptions.DataError(_("Can't have xhtml and rich content at the same time"))
|
raise exceptions.DataError(_("Can't have xhtml and rich content at the same time"))
|
||||||
setattr(_entry, '%s_xhtml' % key, elem)
|
setattr(_entry, '%s_xhtml' % key, elem)
|
||||||
else: # raw text only needs to be escaped to get HTML-safe sequence
|
else: # raw text only needs to be escaped to get HTML-safe sequence
|
||||||
elem = elems[key](escape(data[attr]))
|
elem = elems[key](escape(data[attr]).encode('utf-8'))
|
||||||
elem.attrs['type'] = 'text'
|
elem.attrs['type'] = 'text'
|
||||||
setattr(_entry, key, elem)
|
setattr(_entry, key, elem)
|
||||||
if not getattr(_entry, key).text:
|
if not getattr(_entry, key).text:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue