summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2015-04-14 17:18:34 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2015-04-14 19:14:56 +0200
commit45f7cb8bda42512bad70b6262483ac435209d9c3 (patch)
tree49ca30557429494afab68a885bcabef30a9986ec
parentd5b1904ebb816560a7a0cecf51ac74c6fe9dd6b6 (diff)
downloadslixmpp-45f7cb8bda42512bad70b6262483ac435209d9c3.tar.gz
slixmpp-45f7cb8bda42512bad70b6262483ac435209d9c3.tar.bz2
slixmpp-45f7cb8bda42512bad70b6262483ac435209d9c3.tar.xz
slixmpp-45f7cb8bda42512bad70b6262483ac435209d9c3.zip
XEP-0047: prevent tracebacks in stanza reading.
-rw-r--r--slixmpp/plugins/xep_0047/stanza.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/slixmpp/plugins/xep_0047/stanza.py b/slixmpp/plugins/xep_0047/stanza.py
index 62199077..7f8ff0ba 100644
--- a/slixmpp/plugins/xep_0047/stanza.py
+++ b/slixmpp/plugins/xep_0047/stanza.py
@@ -24,7 +24,7 @@ class Open(ElementBase):
interfaces = set(('block_size', 'sid', 'stanza'))
def get_block_size(self):
- return int(self._get_attr('block-size'))
+ return int(self._get_attr('block-size', '0'))
def set_block_size(self, value):
self._set_attr('block-size', str(value))
@@ -47,7 +47,10 @@ class Data(ElementBase):
self._set_attr('seq', str(value))
def get_data(self):
- b64_data = self.xml.text.strip()
+ text = self.xml.text
+ if not text:
+ raise XMPPError('not-acceptable', 'IBB data element is empty.')
+ b64_data = text.strip()
if VALID_B64.match(b64_data).group() == b64_data:
return from_b64(b64_data)
else: