diff options
author | Philipp Hörist <philipp@hoerist.com> | 2020-02-07 21:57:44 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2020-02-07 21:57:44 +0300 |
commit | 09c2edd3578ae6910c4b9400718ee4a5ee92ecd9 (patch) | |
tree | 055bcfe2faa5a445592c60dcf29afb9033e703a7 | |
parent | 37f5d46ac7529222f15be29781949759ce629f8c (diff) |
Bookmarks: Better handle malformed stanza
Fixes #97
-rw-r--r-- | nbxmpp/modules/bookmarks.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/nbxmpp/modules/bookmarks.py b/nbxmpp/modules/bookmarks.py index 506616d..85ca237 100644 --- a/nbxmpp/modules/bookmarks.py +++ b/nbxmpp/modules/bookmarks.py @@ -225,7 +225,8 @@ class Bookmarks: if type_ == BookmarkStoreType.PUBSUB_BOOKMARK_2: items = get_pubsub_items(stanza, NS_BOOKMARKS_2) if items is None: - return bookmarks + return raise_error(log.warning, stanza, 'stanza-malformed') + for item in items: bookmark_item = self._parse_bookmarks2(item) if bookmark_item is not None: @@ -235,12 +236,20 @@ class Bookmarks: item = get_pubsub_item(stanza) if item is not None: storage_node = item.getTag('storage', namespace=NS_BOOKMARKS) + if storage_node is None: + return raise_error(log.warning, stanza, 'stanza-malformed', + 'No storage node') + if storage_node.getChildren(): bookmarks = self._parse_bookmarks(storage_node) elif type_ == BookmarkStoreType.PRIVATE: query = stanza.getQuery() storage_node = query.getTag('storage', namespace=NS_BOOKMARKS) + if storage_node is None: + return raise_error(log.warning, stanza, 'stanza-malformed', + 'No storage node') + if storage_node.getChildren(): bookmarks = self._parse_bookmarks(storage_node) |