[Kjell Braden] Fix HTML on OTR.

@bct: When moving the OTR stuff, you would've needed to adjust the
XHTML killing part. This patch fixes it. I didn't even notice since
I have XHTML disabled globally.
This commit is contained in:
js 2008-05-27 14:50:54 +00:00
parent c127493e58
commit 6c9063b702
1 changed files with 16 additions and 24 deletions

View File

@ -1650,20 +1650,20 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
encrypted = False encrypted = False
xep_200_encrypted = msg.getTag('c', namespace=common.xmpp.NS_STANZA_CRYPTO) xep_200_encrypted = msg.getTag('c', namespace=common.xmpp.NS_STANZA_CRYPTO)
# I don't trust libotr, that's why I only pass the # We don't trust libotr, that's why we only pass the message
# message to it if it either contains the magic # to it if necessary. otrl_proto_message_type does this check.
# ?OTR string or a plaintext tagged message.
if gajim.otr_module and not xep_200_encrypted \ if gajim.otr_module and not xep_200_encrypted \
and isinstance(msgtxt, unicode) and \ and isinstance(msgtxt, unicode) and \
('\x20\x09\x20\x20\x09\x09\x09\x09\x20\x09\x20\x09\x20\x09\x20\x20' \ gajim.otr_module.otrl_proto_message_type(msgtxt.encode()) != \
in msgtxt or '?OTR' in msgtxt): gajim.otr_module.OTRL_MSGTYPE_NOTOTR:
# If it doesn't include ?OTR, it wasn't an # set to encrypted if it's really encrypted.
# encrypted message, but a tagged plaintext if gajim.otr_module.otrl_proto_message_type(
# message. msgtxt.encode()) != \
if '?OTR' in msgtxt: gajim.otr_module.OTRL_MSGTYPE_TAGGEDPLAINTEXT:
encrypted = True encrypted = True
# TODO: Do we really need .encode()? # TODO: Do we really need .encode()?
# yes we do. OTR can't handle unicode.
otr_msg_tuple = \ otr_msg_tuple = \
gajim.otr_module.otrl_message_receiving( gajim.otr_module.otrl_message_receiving(
self.otr_userstates, self.otr_userstates,
@ -1674,30 +1674,22 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
msgtxt.encode(), msgtxt.encode(),
(gajim.otr_add_appdata, self.name)) (gajim.otr_add_appdata, self.name))
msgtxt = unicode(otr_msg_tuple[1]) msgtxt = unicode(otr_msg_tuple[1])
xhtml = None
html_node = msg.getTag('html')
if html_node:
msg.delChild(html_node)
msg.setBody(msgtxt)
if gajim.otr_module.otrl_tlv_find( if gajim.otr_module.otrl_tlv_find(
otr_msg_tuple[2], otr_msg_tuple[2],
gajim.otr_module.OTRL_TLV_DISCONNECTED) != None: gajim.otr_module.OTRL_TLV_DISCONNECTED) != None:
gajim.otr_ui_ops.gajim_log(_('%s ' \ gajim.otr_ui_ops.gajim_log(_('%s ' \
'has ended his/her private ' \ 'has ended his/her private ' \
'conversation with you.') % frm, 'conversation with you. You should ' \
'do the same.') % frm,
self.name, self.name,
frm.encode()) frm.encode())
# The other end closed the connection,
# so we do the same.
gajim.otr_module. \
otrl_message_disconnect(
self.otr_userstates,
(gajim.otr_ui_ops,
{'account': self.name,
'urgent': True}),
gajim.get_jid_from_account(
self.name).encode(),
gajim.OTR_PROTO,
frm.encode())
ctrls = gajim.interface.msg_win_mgr.get_chat_controls(jid, self.name) ctrls = gajim.interface.msg_win_mgr.get_chat_controls(jid, self.name)
for ctrl in ctrls: for ctrl in ctrls:
ctrl.update_otr() ctrl.update_otr()