From 4cbc0666ff1d0013edf8be2a280053b489ad0e0c Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 15 Mar 2006 08:56:36 +0000 Subject: [PATCH] show an error dialog when a transport answers wrongly to register request. Fixes #1702 --- src/common/connection.py | 5 +++++ src/common/xmpp/features_nb.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/connection.py b/src/common/connection.py index 78fc9a56c..4c5d1d31d 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1674,6 +1674,11 @@ class Connection: if realm == common.xmpp.NS_REGISTER: if event == common.xmpp.features_nb.REGISTER_DATA_RECEIVED: # data is (agent, DataFrom, is_form) + if not data[1]: # wrong answer + self.dispatch('ERROR', (_('Invalid answer'), + _('Transport %s answered wrongly to register request.') % \ + data[0])) + return if self.new_account_info and\ self.new_account_info['hostname'] == data[0]: #it's a new account diff --git a/src/common/xmpp/features_nb.py b/src/common/xmpp/features_nb.py index 63c6b4257..6f4a7326d 100644 --- a/src/common/xmpp/features_nb.py +++ b/src/common/xmpp/features_nb.py @@ -119,7 +119,11 @@ def _ReceivedRegInfo(con, resp, agent): iq=Iq('get',NS_REGISTER,to=agent) if not isResultNode(resp): return - df=resp.getTag('query',namespace=NS_REGISTER).getTag('x',namespace=NS_DATA) + tag=resp.getTag('query',namespace=NS_REGISTER) + if not tag: + con.Event(NS_REGISTER,REGISTER_DATA_RECEIVED,(agent,None,False)) + return + df=tag.getTag('x',namespace=NS_DATA) if df: con.Event(NS_REGISTER,REGISTER_DATA_RECEIVED,(agent,DataForm(node=df),True)) return