Some messages will generate a exception like the one below, if they are
missing the ID attribute.

Traceback (most recent call last):
[snip]
  File "[...]/pymsnt-0.10/src/disco.py", line 135, in onIq
    handler(el)
  File "[...]/pymsnt-0.10/src/misciq.py", line 273, in incomingIq
    self.pytrans.send(iq)
  File 
"/usr/lib/python2.4/site-packages/twisted/words/protocols/jabber/component.py", 
line 84, in send
    self.parent.send(obj)
  File 
"/usr/lib/python2.4/site-packages/twisted/words/protocols/jabber/component.py", 
line 151, in send
    self.xmlstream.send(obj)
  File "/usr/lib/python2.4/site-packages/twisted/xish/xmlstream.py", line 179, 
in send
    obj = obj.toXml()
  File "/usr/lib/python2.4/site-packages/twisted/xish/domish.py", line 400, in 
toXml
    s.serialize(self, closeElement)
  File "/usr/lib/python2.4/site-packages/twisted/xish/domish.py", line 86, in 
serialize
    write((" %s='%s'" % ( k, escapeToXml(v, 1))).encode("utf-8"))
  File "/usr/lib/python2.4/site-packages/twisted/xish/domish.py", line 198, in 
escapeToXml
    text = text.replace("&", "&")
exceptions.AttributeError: 'NoneType' object has no attribute 'replace'

A patch to check for missing ID attributes is attached.

Best regards,
Lars
-------------- next part --------------
Index: misciq.py
===================================================================
RCS file: /home/cvs/msn-transport/PyMSNt/src/misciq.py,v
retrieving revision 1.4.2.30
diff -u -r1.4.2.30 misciq.py
--- misciq.py   11 Sep 2005 01:59:41 -0000      1.4.2.30
+++ misciq.py   19 Oct 2005 16:39:49 -0000
@@ -172,7 +172,8 @@
                iq = Element((None, "iq"))
                iq.attributes["to"] = to
                iq.attributes["from"] = config.jid
-               iq.attributes["id"] = ID
+               if(ID):
+                       iq.attributes["id"] = ID
                iq.attributes["type"] = "result"
 
                query = iq.addElement("query")
@@ -251,7 +252,8 @@
                iq = Element((None, "iq"))
                iq.attributes["to"] = fro
                iq.attributes["from"] = to
-               iq.attributes["id"] = ID
+               if(ID):
+                       iq.attributes["id"] = ID
                iq.attributes["type"] = "result"
                vCard = iq.addElement("vCard")
                vCard.attributes["xmlns"] = "vcard-temp"
@@ -307,7 +309,8 @@
                iq = Element((None, "iq"))
                iq.attributes["to"] = fro
                iq.attributes["from"] = to
-               iq.attributes["id"] = ID
+               if(ID):
+                       iq.attributes["id"] = ID
                iq.attributes["type"] = "result"
                query = iq.addElement("query")
                query.attributes["xmlns"] = "jabber:iq:avatar"
@@ -381,7 +384,8 @@
                iq.attributes["type"] = "result"
                iq.attributes["from"] = config.jid
                iq.attributes["to"] = to
-               iq.attributes["id"] = ID
+               if(ID):
+                       iq.attributes["id"] = ID
                query = iq.addElement("query")
                query.attributes["xmlns"] = "jabber:iq:gateway"
                desc = query.addElement("desc")
@@ -410,7 +414,8 @@
                        iq.attributes["type"] = "result"
                        iq.attributes["from"] = config.jid
                        iq.attributes["to"] = to
-                       iq.attributes["id"] = ID
+                       if(ID):
+                               iq.attributes["id"] = ID
                        query = iq.addElement("query")
                        query.attributes["xmlns"] = "jabber:iq:gateway"
                        prompt = query.addElement("prompt")
Index: register.py
===================================================================
RCS file: /home/cvs/msn-transport/PyMSNt/src/register.py,v
retrieving revision 1.6.2.8
diff -u -r1.6.2.8 register.py
--- register.py 10 Sep 2005 10:12:26 -0000      1.6.2.8
+++ register.py 19 Oct 2005 16:39:49 -0000
@@ -77,7 +77,9 @@
                reply = Element((None, "iq"))
                reply.attributes["from"] = config.jid
                reply.attributes["to"] = incoming.getAttribute("from")
-               reply.attributes["id"] = incoming.getAttribute("id")
+               ID = incoming.getAttribute("id")
+               if(ID):
+                       reply.attributes["id"] = ID
                reply.attributes["type"] = "result"
                query = reply.addElement("query")
                query.attributes["xmlns"] = "jabber:iq:register"
From [EMAIL PROTECTED]  Wed Oct 19 23:26:35 2005
From: [EMAIL PROTECTED] (James Bunton)
Date: Wed Oct 19 23:26:45 2005
Subject: [py-transports] PyMSNt: Exception when ID attribute is missing
In-Reply-To: <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

Thanks.

This will go in for the next release.

Although the clients sending these are buggy, and they should be fixed.  
Any idea which clients are the culprits?

---

James



On 20/10/2005, at 2:43 AM, Lars T. Mikkelsen wrote:

> Some messages will generate a exception like the one below, if they are
> missing the ID attribute.
>
> Traceback (most recent call last):
> [snip]
>   File "[...]/pymsnt-0.10/src/disco.py", line 135, in onIq
>     handler(el)
>   File "[...]/pymsnt-0.10/src/misciq.py", line 273, in incomingIq
>     self.pytrans.send(iq)
>   File  
> "/usr/lib/python2.4/site-packages/twisted/words/protocols/jabber/ 
> component.py", line 84, in send
>     self.parent.send(obj)
>   File  
> "/usr/lib/python2.4/site-packages/twisted/words/protocols/jabber/ 
> component.py", line 151, in send
>     self.xmlstream.send(obj)
>   File "/usr/lib/python2.4/site-packages/twisted/xish/xmlstream.py",  
> line 179, in send
>     obj = obj.toXml()
>   File "/usr/lib/python2.4/site-packages/twisted/xish/domish.py", line  
> 400, in toXml
>     s.serialize(self, closeElement)
>   File "/usr/lib/python2.4/site-packages/twisted/xish/domish.py", line  
> 86, in serialize
>     write((" %s='%s'" % ( k, escapeToXml(v, 1))).encode("utf-8"))
>   File "/usr/lib/python2.4/site-packages/twisted/xish/domish.py", line  
> 198, in escapeToXml
>     text = text.replace("&", "&amp;")
> exceptions.AttributeError: 'NoneType' object has no attribute 'replace'
>
> A patch to check for missing ID attributes is attached.
>
> Best regards,
> Lars
> <check-id- 
> attributes.patch>_______________________________________________
> py-transports mailing list
> py-transports@blathersource.org
> http://www.modevia.com/cgi-bin/mailman/listinfo/py-transports

Reply via email to