fix: unsupported typ= parameter in OTR plugin
still broken because of pycrypto though
This commit is contained in:
parent
abb587f237
commit
2b032b7d02
1 changed files with 34 additions and 32 deletions
|
@ -388,29 +388,27 @@ class PoezioContext(Context):
|
||||||
log.debug('OTR conversation with %s refreshed', self.peer)
|
log.debug('OTR conversation with %s refreshed', self.peer)
|
||||||
if self.getCurrentTrust():
|
if self.getCurrentTrust():
|
||||||
msg = OTR_REFRESH_TRUSTED % format_dict
|
msg = OTR_REFRESH_TRUSTED % format_dict
|
||||||
tab.add_message(InfoMessage(msg), typ=self.log)
|
tab.add_message(InfoMessage(msg))
|
||||||
else:
|
else:
|
||||||
msg = OTR_REFRESH_UNTRUSTED % format_dict
|
msg = OTR_REFRESH_UNTRUSTED % format_dict
|
||||||
tab.add_message(InfoMessage(msg), typ=self.log)
|
tab.add_message(InfoMessage(msg))
|
||||||
hl(tab)
|
hl(tab)
|
||||||
elif newstate == STATE_FINISHED or newstate == STATE_PLAINTEXT:
|
elif newstate == STATE_FINISHED or newstate == STATE_PLAINTEXT:
|
||||||
log.debug('OTR conversation with %s finished', self.peer)
|
log.debug('OTR conversation with %s finished', self.peer)
|
||||||
if tab:
|
if tab:
|
||||||
tab.add_message(InfoMessage(OTR_END % format_dict), typ=self.log)
|
tab.add_message(InfoMessage(OTR_END % format_dict))
|
||||||
hl(tab)
|
hl(tab)
|
||||||
elif newstate == STATE_ENCRYPTED and tab:
|
elif newstate == STATE_ENCRYPTED and tab:
|
||||||
if self.getCurrentTrust():
|
if self.getCurrentTrust():
|
||||||
tab.add_message(InfoMessage(OTR_START_TRUSTED % format_dict), typ=self.log)
|
tab.add_message(InfoMessage(OTR_START_TRUSTED % format_dict))
|
||||||
else:
|
else:
|
||||||
format_dict['our_fpr'] = self.user.getPrivkey()
|
format_dict['our_fpr'] = self.user.getPrivkey()
|
||||||
format_dict['remote_fpr'] = self.getCurrentKey()
|
format_dict['remote_fpr'] = self.getCurrentKey()
|
||||||
tab.add_message(
|
tab.add_message(
|
||||||
InfoMessage(OTR_TUTORIAL % format_dict),
|
InfoMessage(OTR_TUTORIAL % format_dict),
|
||||||
typ=0
|
|
||||||
)
|
)
|
||||||
tab.add_message(
|
tab.add_message(
|
||||||
InfoMessage(OTR_START_UNTRUSTED % format_dict),
|
InfoMessage(OTR_START_UNTRUSTED % format_dict),
|
||||||
typ=self.log,
|
|
||||||
)
|
)
|
||||||
hl(tab)
|
hl(tab)
|
||||||
|
|
||||||
|
@ -650,7 +648,7 @@ class Plugin(BasePlugin):
|
||||||
# Received an OTR error
|
# Received an OTR error
|
||||||
proto_error = err.args[0].error # pylint: disable=no-member
|
proto_error = err.args[0].error # pylint: disable=no-member
|
||||||
format_dict['err'] = proto_error.decode('utf-8', errors='replace')
|
format_dict['err'] = proto_error.decode('utf-8', errors='replace')
|
||||||
tab.add_message(InfoMessage(OTR_ERROR % format_dict), typ=0)
|
tab.add_message(InfoMessage(OTR_ERROR % format_dict))
|
||||||
del msg['body']
|
del msg['body']
|
||||||
del msg['html']
|
del msg['html']
|
||||||
hl(tab)
|
hl(tab)
|
||||||
|
@ -660,7 +658,7 @@ class Plugin(BasePlugin):
|
||||||
# Encrypted message received, but unreadable as we do not have
|
# Encrypted message received, but unreadable as we do not have
|
||||||
# an OTR session in place.
|
# an OTR session in place.
|
||||||
text = MESSAGE_UNREADABLE % format_dict
|
text = MESSAGE_UNREADABLE % format_dict
|
||||||
tab.add_message(InfoMessage(text), typ=0)
|
tab.add_message(InfoMessage(text))
|
||||||
hl(tab)
|
hl(tab)
|
||||||
del msg['body']
|
del msg['body']
|
||||||
del msg['html']
|
del msg['html']
|
||||||
|
@ -669,7 +667,7 @@ class Plugin(BasePlugin):
|
||||||
except crypt.InvalidParameterError:
|
except crypt.InvalidParameterError:
|
||||||
# Malformed OTR payload and stuff
|
# Malformed OTR payload and stuff
|
||||||
text = MESSAGE_INVALID % format_dict
|
text = MESSAGE_INVALID % format_dict
|
||||||
tab.add_message(InfoMessage(text), typ=0)
|
tab.add_message(InfoMessage(text))
|
||||||
hl(tab)
|
hl(tab)
|
||||||
del msg['body']
|
del msg['body']
|
||||||
del msg['html']
|
del msg['html']
|
||||||
|
@ -680,7 +678,7 @@ class Plugin(BasePlugin):
|
||||||
import traceback
|
import traceback
|
||||||
exc = traceback.format_exc()
|
exc = traceback.format_exc()
|
||||||
format_dict['exc'] = exc
|
format_dict['exc'] = exc
|
||||||
tab.add_message(InfoMessage(POTR_ERROR % format_dict), typ=0)
|
tab.add_message(InfoMessage(POTR_ERROR % format_dict))
|
||||||
log.error('Unspecified error in the OTR plugin', exc_info=True)
|
log.error('Unspecified error in the OTR plugin', exc_info=True)
|
||||||
return
|
return
|
||||||
# No error, proceed with the message
|
# No error, proceed with the message
|
||||||
|
@ -699,10 +697,10 @@ class Plugin(BasePlugin):
|
||||||
abort = get_tlv(tlvs, potr.proto.SMPABORTTLV)
|
abort = get_tlv(tlvs, potr.proto.SMPABORTTLV)
|
||||||
if abort:
|
if abort:
|
||||||
ctx.reset_smp()
|
ctx.reset_smp()
|
||||||
tab.add_message(InfoMessage(SMP_ABORTED_PEER % format_dict), typ=0)
|
tab.add_message(InfoMessage(SMP_ABORTED_PEER % format_dict))
|
||||||
elif ctx.in_smp and not ctx.smpIsValid():
|
elif ctx.in_smp and not ctx.smpIsValid():
|
||||||
ctx.reset_smp()
|
ctx.reset_smp()
|
||||||
tab.add_message(InfoMessage(SMP_ABORTED % format_dict), typ=0)
|
tab.add_message(InfoMessage(SMP_ABORTED % format_dict))
|
||||||
elif smp1 or smp1q:
|
elif smp1 or smp1q:
|
||||||
# Received an SMP request (with a question or not)
|
# Received an SMP request (with a question or not)
|
||||||
if smp1q:
|
if smp1q:
|
||||||
|
@ -720,22 +718,22 @@ class Plugin(BasePlugin):
|
||||||
# we did not initiate it
|
# we did not initiate it
|
||||||
ctx.smp_own = False
|
ctx.smp_own = False
|
||||||
format_dict['q'] = question
|
format_dict['q'] = question
|
||||||
tab.add_message(InfoMessage(SMP_REQUESTED % format_dict), typ=0)
|
tab.add_message(InfoMessage(SMP_REQUESTED % format_dict))
|
||||||
elif smp2:
|
elif smp2:
|
||||||
# SMP reply received
|
# SMP reply received
|
||||||
if not ctx.in_smp:
|
if not ctx.in_smp:
|
||||||
ctx.reset_smp()
|
ctx.reset_smp()
|
||||||
else:
|
else:
|
||||||
tab.add_message(InfoMessage(SMP_PROGRESS % format_dict), typ=0)
|
tab.add_message(InfoMessage(SMP_PROGRESS % format_dict))
|
||||||
elif smp3 or smp4:
|
elif smp3 or smp4:
|
||||||
# Type 4 (SMP message 3) or 5 (SMP message 4) TLVs received
|
# Type 4 (SMP message 3) or 5 (SMP message 4) TLVs received
|
||||||
# in both cases it is the final message of the SMP exchange
|
# in both cases it is the final message of the SMP exchange
|
||||||
if ctx.smpIsSuccess():
|
if ctx.smpIsSuccess():
|
||||||
tab.add_message(InfoMessage(SMP_SUCCESS % format_dict), typ=0)
|
tab.add_message(InfoMessage(SMP_SUCCESS % format_dict))
|
||||||
if not ctx.getCurrentTrust():
|
if not ctx.getCurrentTrust():
|
||||||
tab.add_message(InfoMessage(SMP_RECIPROCATE % format_dict), typ=0)
|
tab.add_message(InfoMessage(SMP_RECIPROCATE % format_dict))
|
||||||
else:
|
else:
|
||||||
tab.add_message(InfoMessage(SMP_FAIL % format_dict), typ=0)
|
tab.add_message(InfoMessage(SMP_FAIL % format_dict))
|
||||||
ctx.reset_smp()
|
ctx.reset_smp()
|
||||||
hl(tab)
|
hl(tab)
|
||||||
self.core.refresh_window()
|
self.core.refresh_window()
|
||||||
|
@ -747,7 +745,13 @@ class Plugin(BasePlugin):
|
||||||
"""
|
"""
|
||||||
format_dict['msg'] = err.args[0].decode('utf-8')
|
format_dict['msg'] = err.args[0].decode('utf-8')
|
||||||
text = MESSAGE_UNENCRYPTED % format_dict
|
text = MESSAGE_UNENCRYPTED % format_dict
|
||||||
tab.add_message(text, jid=msg['from'], typ=ctx.log)
|
tab.add_message(
|
||||||
|
Message(
|
||||||
|
text,
|
||||||
|
nickname=tab.nick,
|
||||||
|
jid=msg['from'],
|
||||||
|
),
|
||||||
|
)
|
||||||
del msg['body']
|
del msg['body']
|
||||||
del msg['html']
|
del msg['html']
|
||||||
hl(tab)
|
hl(tab)
|
||||||
|
@ -798,7 +802,6 @@ class Plugin(BasePlugin):
|
||||||
user=user,
|
user=user,
|
||||||
nick_color=nick_color
|
nick_color=nick_color
|
||||||
),
|
),
|
||||||
typ=ctx.log,
|
|
||||||
)
|
)
|
||||||
hl(tab)
|
hl(tab)
|
||||||
self.core.refresh_window()
|
self.core.refresh_window()
|
||||||
|
@ -849,7 +852,6 @@ class Plugin(BasePlugin):
|
||||||
identifier=msg['id'],
|
identifier=msg['id'],
|
||||||
jid=self.core.xmpp.boundjid,
|
jid=self.core.xmpp.boundjid,
|
||||||
),
|
),
|
||||||
typ=ctx.log
|
|
||||||
)
|
)
|
||||||
# remove everything from the message so that it doesn’t get sent
|
# remove everything from the message so that it doesn’t get sent
|
||||||
del msg['body']
|
del msg['body']
|
||||||
|
@ -857,7 +859,7 @@ class Plugin(BasePlugin):
|
||||||
del msg['html']
|
del msg['html']
|
||||||
elif is_relevant(tab) and ctx and ctx.getPolicy('REQUIRE_ENCRYPTION'):
|
elif is_relevant(tab) and ctx and ctx.getPolicy('REQUIRE_ENCRYPTION'):
|
||||||
warning_msg = MESSAGE_NOT_SENT % format_dict
|
warning_msg = MESSAGE_NOT_SENT % format_dict
|
||||||
tab.add_message(InfoMessage(warning_msg), typ=0)
|
tab.add_message(InfoMessage(warning_msg))
|
||||||
del msg['body']
|
del msg['body']
|
||||||
del msg['replace']
|
del msg['replace']
|
||||||
del msg['html']
|
del msg['html']
|
||||||
|
@ -875,7 +877,7 @@ class Plugin(BasePlugin):
|
||||||
('\n - /message %s' % jid) for jid in res)
|
('\n - /message %s' % jid) for jid in res)
|
||||||
format_dict['help'] = help_msg
|
format_dict['help'] = help_msg
|
||||||
warning_msg = INCOMPATIBLE_TAB % format_dict
|
warning_msg = INCOMPATIBLE_TAB % format_dict
|
||||||
tab.add_message(InfoMessage(warning_msg), typ=0)
|
tab.add_message(InfoMessage(warning_msg))
|
||||||
del msg['body']
|
del msg['body']
|
||||||
del msg['replace']
|
del msg['replace']
|
||||||
del msg['html']
|
del msg['html']
|
||||||
|
@ -923,22 +925,22 @@ class Plugin(BasePlugin):
|
||||||
self.otr_start(tab, name, format_dict)
|
self.otr_start(tab, name, format_dict)
|
||||||
elif action == 'ourfpr':
|
elif action == 'ourfpr':
|
||||||
format_dict['fpr'] = self.account.getPrivkey()
|
format_dict['fpr'] = self.account.getPrivkey()
|
||||||
tab.add_message(InfoMessage(OTR_OWN_FPR % format_dict), typ=0)
|
tab.add_message(InfoMessage(OTR_OWN_FPR % format_dict))
|
||||||
elif action == 'fpr':
|
elif action == 'fpr':
|
||||||
if name in self.contexts:
|
if name in self.contexts:
|
||||||
ctx = self.contexts[name]
|
ctx = self.contexts[name]
|
||||||
if ctx.getCurrentKey() is not None:
|
if ctx.getCurrentKey() is not None:
|
||||||
format_dict['fpr'] = ctx.getCurrentKey()
|
format_dict['fpr'] = ctx.getCurrentKey()
|
||||||
tab.add_message(InfoMessage(OTR_REMOTE_FPR % format_dict), typ=0)
|
tab.add_message(InfoMessage(OTR_REMOTE_FPR % format_dict))
|
||||||
else:
|
else:
|
||||||
tab.add_message(InfoMessage(OTR_NO_FPR % format_dict), typ=0)
|
tab.add_message(InfoMessage(OTR_NO_FPR % format_dict))
|
||||||
elif action == 'drop':
|
elif action == 'drop':
|
||||||
# drop the privkey (and obviously, end the current conversations before that)
|
# drop the privkey (and obviously, end the current conversations before that)
|
||||||
for context in self.contexts.values():
|
for context in self.contexts.values():
|
||||||
if context.state not in (STATE_FINISHED, STATE_PLAINTEXT):
|
if context.state not in (STATE_FINISHED, STATE_PLAINTEXT):
|
||||||
context.disconnect()
|
context.disconnect()
|
||||||
self.account.drop_privkey()
|
self.account.drop_privkey()
|
||||||
tab.add_message(InfoMessage(KEY_DROPPED % format_dict), typ=0)
|
tab.add_message(InfoMessage(KEY_DROPPED % format_dict))
|
||||||
elif action == 'trust':
|
elif action == 'trust':
|
||||||
ctx = self.get_context(name)
|
ctx = self.get_context(name)
|
||||||
key = ctx.getCurrentKey()
|
key = ctx.getCurrentKey()
|
||||||
|
@ -950,7 +952,7 @@ class Plugin(BasePlugin):
|
||||||
format_dict['key'] = key
|
format_dict['key'] = key
|
||||||
ctx.setTrust(fpr, 'verified')
|
ctx.setTrust(fpr, 'verified')
|
||||||
self.account.saveTrusts()
|
self.account.saveTrusts()
|
||||||
tab.add_message(InfoMessage(TRUST_ADDED % format_dict), typ=0)
|
tab.add_message(InfoMessage(TRUST_ADDED % format_dict))
|
||||||
elif action == 'untrust':
|
elif action == 'untrust':
|
||||||
ctx = self.get_context(name)
|
ctx = self.get_context(name)
|
||||||
key = ctx.getCurrentKey()
|
key = ctx.getCurrentKey()
|
||||||
|
@ -962,7 +964,7 @@ class Plugin(BasePlugin):
|
||||||
format_dict['key'] = key
|
format_dict['key'] = key
|
||||||
ctx.setTrust(fpr, '')
|
ctx.setTrust(fpr, '')
|
||||||
self.account.saveTrusts()
|
self.account.saveTrusts()
|
||||||
tab.add_message(InfoMessage(TRUST_REMOVED % format_dict), typ=0)
|
tab.add_message(InfoMessage(TRUST_REMOVED % format_dict))
|
||||||
self.core.refresh_window()
|
self.core.refresh_window()
|
||||||
|
|
||||||
def otr_start(self, tab, name, format_dict):
|
def otr_start(self, tab, name, format_dict):
|
||||||
|
@ -977,7 +979,7 @@ class Plugin(BasePlugin):
|
||||||
if otr.state != STATE_ENCRYPTED:
|
if otr.state != STATE_ENCRYPTED:
|
||||||
format_dict['secs'] = secs
|
format_dict['secs'] = secs
|
||||||
text = OTR_NOT_ENABLED % format_dict
|
text = OTR_NOT_ENABLED % format_dict
|
||||||
tab.add_message(InfoMessage(text), typ=0)
|
tab.add_message(InfoMessage(text))
|
||||||
self.core.refresh_window()
|
self.core.refresh_window()
|
||||||
|
|
||||||
if secs > 0:
|
if secs > 0:
|
||||||
|
@ -985,7 +987,7 @@ class Plugin(BasePlugin):
|
||||||
self.api.add_timed_event(event)
|
self.api.add_timed_event(event)
|
||||||
body = self.get_context(name).sendMessage(0, b'?OTRv?').decode()
|
body = self.get_context(name).sendMessage(0, b'?OTRv?').decode()
|
||||||
self.core.xmpp.send_message(mto=name, mtype='chat', mbody=body)
|
self.core.xmpp.send_message(mto=name, mtype='chat', mbody=body)
|
||||||
tab.add_message(InfoMessage(OTR_REQUEST % format_dict), typ=0)
|
tab.add_message(InfoMessage(OTR_REQUEST % format_dict))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def completion_otr(the_input):
|
def completion_otr(the_input):
|
||||||
|
@ -1035,13 +1037,13 @@ class Plugin(BasePlugin):
|
||||||
ctx.smpInit(secret, question)
|
ctx.smpInit(secret, question)
|
||||||
else:
|
else:
|
||||||
ctx.smpInit(secret)
|
ctx.smpInit(secret)
|
||||||
tab.add_message(InfoMessage(SMP_INITIATED % format_dict), typ=0)
|
tab.add_message(InfoMessage(SMP_INITIATED % format_dict))
|
||||||
elif action == 'answer':
|
elif action == 'answer':
|
||||||
ctx.smpGotSecret(secret)
|
ctx.smpGotSecret(secret)
|
||||||
elif action == 'abort':
|
elif action == 'abort':
|
||||||
if ctx.in_smp:
|
if ctx.in_smp:
|
||||||
ctx.smpAbort()
|
ctx.smpAbort()
|
||||||
tab.add_message(InfoMessage(SMP_ABORTED % format_dict), typ=0)
|
tab.add_message(InfoMessage(SMP_ABORTED % format_dict))
|
||||||
self.core.refresh_window()
|
self.core.refresh_window()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in a new issue