Mercurial > libervia-pubsub
changeset 47:31eb00734cc5
Check for malformed unsubscribe request.
author | Ralph Meijer <ralphm@ik.nu> |
---|---|
date | Wed, 03 Nov 2004 15:55:13 +0000 |
parents | 979e53b54267 |
children | 671ead538758 |
files | idavoll/pubsub.py |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/idavoll/pubsub.py Wed Nov 03 14:06:08 2004 +0000 +++ b/idavoll/pubsub.py Wed Nov 03 15:55:13 2004 +0000 @@ -33,6 +33,9 @@ class NotImplemented(Error): stanza_error = 'feature-not-implemented' +class BadRequest(Error): + stanza_error = 'bad-request' + class OptionsUnavailable(Error): stanza_error = 'feature-not-implemented' pubsub_error = 'subscription-options-unavailable' @@ -49,6 +52,8 @@ stanza_error = 'not-acceptable' pubsub_error = 'node-not-configurable' + + error_map = { backend.NotAuthorized: ('not-authorized', None), backend.NodeNotFound: ('item-not-found', None), @@ -219,8 +224,13 @@ self.handler_wrapper(self._onUnsubscribe, iq) def _onUnsubscribe(self, iq): - node_id = iq.pubsub.unsubscribe["node"] - subscriber = jid.JID(iq.pubsub.unsubscribe["jid"]) + try: + node_id = iq.pubsub.unsubscribe["node"] + jid = iq.pubsub.unsubscribe["jid"] + except KeyError: + raise BadRequest + + subscriber = jid.JID(jid) requestor = jid.JID(iq["from"]).userhostJID() return self.backend.unsubscribe(node_id, subscriber, requestor)