Ticket #24 (closed defect: worksforme)

Opened 2 years ago

Last modified 19 months ago

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

Changed 2 years ago by http://openid.jajcus.net/jajcus/

That namespace is internally used by PyXMPP and should be removed (also by PyXMPP) when the stanza is sent. I am not sure why that failed in your case. Your code seems quite good and maybe it could replace the temporary-namespace-stripping code currently used by PyXMPP.

Changed 19 months ago by jajcus

  • status changed from new to closed
  • resolution set to worksforme

I think this one can be closed. I have never seen this problem myself and the temporary namespace stripping code has been updated since this ticket was opened.

Reopen or create a new bug report if the problem still occurs.

Note: See TracTickets for help on using tickets.