Ticket #24 (closed defect: worksforme)
Message.make_error_response sets weird namespaces
| Reported by: | leon@… | Owned by: | jajcus |
|---|---|---|---|
| Priority: | major | Component: | pyxmpp |
| Keywords: | Cc: |
Description
<message to="sipnet.darkk.net.ru" id="aac9a" > <subject>@subj@</subject> <body>@msg@</body> <nick xmlns="http://jabber.org/protocol/nick">darkk</nick> </message>
pyxmpp-based handler has following code:
def _message_any(self, msg): user = self.registry.get(jid_to_dbkey(msg.get_from())) if user is None: self.stream.send(msg.make_error_response('forbidden')) return True ...
and this code produces following stanza coming to client:
<message from="sipnet.darkk.net.ru" type="error" to="leon@darkk.net.ru/Psi" id="aac9a" > <nick xmlns="http://jabber.org/protocol/nick">darkk</nick> <body xmlns="http://pyxmpp.jabberstudio.org/xmlns/common">@msg@</body> <subject xmlns="http://pyxmpp.jabberstudio.org/xmlns/common">@subj@</subject> <error type="auth" code="403" > <forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/> </error> </message>
As far as I understand, subject and body have incorrect namespace (and psi ignores these body and subject).
Possible hackish workaround is to call
def strip_pyxmpp_ns(stanza): from pyxmpp.xmlextra import COMMON_NS, common_doc namespaces = {'pyxmpp': COMMON_NS } badnodes = stanza.xpath_eval('pyxmpp:*', namespaces) if badnodes: logging.debug("pyxmpp bug workaround: striping namespace from %s" % badnodes) for node in badnodes: nslist = node.removeNsDef(COMMON_NS) if nslist is not None: node.reconciliateNs(common_doc) nslist.freeNsList()
Change History
Note: See
TracTickets for help on using
tickets.