Giter Club home page Giter Club logo

pyxmpp2's Introduction

PyXMPP2 – Python Jabber/XMPP implementation

Note: This code is far from being complete and is not actively developed. Though, it has proven to be useful for some, anyway.

Introduction

The goal of this project is to rewrite PyXMPP so:

  • it doesn't rely on libxml2 any more
  • it uses most current Python APIs
  • its API is cleaned up
  • etc.

Requirements

  • Python 2.7 or 3.3 or newer
  • DNSPython Limited functionality is available without it.

Python 3 support

The source code is written for Python 2.7, but automated facilities are available for conversion to 3.3. For this to work you need the Distribute package installed for Python 3.

To build or install the py3k package run the setup.py script using the Python 3 interpreter:

python3 setup.py build
python3 setup.py install

You may want to give --build-base py3-build option to build if you are also building Python 2 version.

If you have the GNU Make utility (every Linux distribution provides it) you may use make command instead:

make py3-build
make py3-install

Those will also make the Python3 version of the examples in the py3-examples directory if you are using a GIT checkout (source distributions already provide those).

As for now (2011-07-02) there is no official DNSPython release for Python 3, you may want to check their experimental branch.

Features

  • RFC 6120 – XMPP Core:
    • SRV record look-up (requires DNSPython)
    • XML streams:
      • both initiator and receiver side
      • 'xml:lang' attribute handling on the root element
      • 'version' attribute handling, including special '0.9' (no version) case
      • full XML namespace support
      • does not generate and does not accept XML that is not well-formed
      • stream errors
    • StartTLS:
      • initiator (client) side implemented
      • cerificate verification:
        • 'Subject Alt Name' / 'DNS' field
        • 'Subject' / 'Common Name' field
    • SASL:
      • both initiator and receiver side
      • supported mechanisms:
        • PLAIN
        • DIGEST-MD5
        • SCRAM-SHA-1
        • SCRAM-SHA-1-PLUS (python 3.3, not released yet, needed)
    • Resource binding
    • XMPP Stanzas:
      • <iq/>, <presence/> and <message/> stanzas
      • stanza errors
  • RFC 6121 – XMPP Instant Messaging and Presence:
    • Roster Management:
      • versioned rosters
      • subscription pre-approval flag
  • RFC 6122 – XMPP Address Format:
    • Full unicode support
    • 'Nameprep' strinprep profile for the local part (for validation and comparision)
    • 'Resourceprep' for the resource part
    • 'IDNA' encoding for the domain part
  • XMPP Extensions:
  • I/O framework:
    • asynchronous main event loop
    • alternative implementation with threads
    • non-blocking connect
    • non-blocking TLS handshake
  • stanza processing framework:
    • chained handlers for <message/> and <presence/> stanzas, matched by stanza type and, optionally, payload class (derivied from namespace-qualified element name)
    • handlers for <iq type='get'/> and <iq type='set'/> stanzas, matched by payload element name (namespace-qualified)
    • handlers for <iq type='result'/> and <iq type='error'/> registered for outbound <iq type='get'/> and <iq type='set'/> stanzas and matched by the stanza id

A bit more formal list of the XMPP features implemented is available in the wiki: https://github.com/Jajcus/pyxmpp2/wiki/Conformance-declaration

Contact

pyxmpp2's People

Contributors

hensing avatar jajcus avatar lilydjwg avatar lpsinger avatar rxwen avatar smallevilbeast avatar timgates42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyxmpp2's Issues

sha module deprecated

python 2.6 and pyxmpp 1.0.1 results in
{{{
.../pyxmpp/jabberd/componentstream.py:27: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
}}}
pls fix :)

Copy of the PyXMPP issue Jajcus/pyxmpp#32

iq with unknown type

iq with unknown type makes jabber loop throw exception.

how to reproduce:

send such iq from Psi XML console:

and application listening on [email protected]/someresource will exit with such traceback:

Traceback (most recent call last):
File "core.py", line 28, in ?
jab.loop(1)
File "/usr/lib/python2.4/site-packages/pyxmpp/client.py", line 240, in loop
act=stream.loop_iter(timeout)
File "/usr/lib/python2.4/site-packages/pyxmpp/streambase.py", line 619, in loop_iter
return self._loop_iter(timeout)
File "/usr/lib/python2.4/site-packages/pyxmpp/streambase.py", line 637, in _loop_iter
self._process()
File "/usr/lib/python2.4/site-packages/pyxmpp/streamtls.py", line 178, in _process
StreamBase._process(self)
File "/usr/lib/python2.4/site-packages/pyxmpp/streambase.py", line 658, in _process
self._read()
File "/usr/lib/python2.4/site-packages/pyxmpp/streamtls.py", line 173, in _read
StreamBase._read(self)
File "/usr/lib/python2.4/site-packages/pyxmpp/streambase.py", line 682, in _read
self._feed_reader(r)
File "/usr/lib/python2.4/site-packages/pyxmpp/streambase.py", line 698, in _feed_reader
r=self._reader.feed(data)
File "/usr/lib/python2.4/site-packages/pyxmpp/xmlextra.py", line 539, in feed
return self.reader.feed(s)
File "/usr/lib/python2.4/site-packages/pyxmpp/xmlextra.py", line 59, in _stanza
self.stanza(doc,node)
File "/usr/lib/python2.4/site-packages/pyxmpp/streambase.py", line 422, in stanza
self._process_node(node)
File "/usr/lib/python2.4/site-packages/pyxmpp/stream.py", line 107, in _process_node
StreamBase._process_node(self,xmlnode)
File "/usr/lib/python2.4/site-packages/pyxmpp/streambase.py", line 731, in _process_node
self.process_stanza(stanza)
File "/usr/lib/python2.4/site-packages/pyxmpp/stanzaprocessor.py", line 235, in process_stanza
if self.process_iq(stanza):
File "/usr/lib/python2.4/site-packages/pyxmpp/stanzaprocessor.py", line 111, in process_iq
r=stanza.make_error_response("feature-not-implemented")
File "/usr/lib/python2.4/site-packages/pyxmpp/iq.py", line 99, in make_error_response
raise StanzaError,"Errors may only be generated for 'set' or 'get' iq"
pyxmpp.stanza.StanzaError: Errors may only be generated for 'set' or 'get' iq

Copy of the PyXMPP issue Jajcus/pyxmpp#3

Generate comman-line option parser for common settings

Most command-line based PyXMPP2 application would need similar command line interface to initialize the XMPPSettings object. This should be automated in PyXMPP. All needed meta-data is already there.

There should be an interface to return an argparse.ArgumentParser instance with a common options. It should be flexible-enough for most common use cases.

VCardAdr parsing error

lines 489 and 490 need to be reversed in [source:trunk/pyxmpp/jabber/vcard.py##L489 vcard.py]
{{{
value=[""]_7
v=value.split(";")
}}}
should be
{{{
v=value.split(";")
value=[""]_7
}}}

Copy of the PyXMPP issue Jajcus/pyxmpp#12

raw xml stream

hi, I'm looking some way to monitor raw xml stream, and noticed that in changelog of 2003:

2003-08-08 08:02 +0000 [r96] Jacek Konieczny [email protected]
* pyxmpp/stream.py:
- data_in() and data_out() methods to override for 'raw XML
console'

but data_in() and data_out methods are missing in the new version.
How can I monitor the raw xml stream?

Copy of the PyXMPP issue Jajcus/pyxmpp#29

TestCacheItem.test_item_state_transitions non-deterministic

While minor, I have seen this test fail by "skipping" intermediate cache states which are expected to be visited during the test. To make the test completely reliable, we basically need to know the last "update time" for the cache item (expose the 'now' obtained in CacheItem.update_state), and make sure the clock difference corresponds to the correct cache state.
I'm attaching a sample diff for a new test and CacheItem which exposes the last cache update time (although we probably shouldn't change the internals just to get the test to pass reliably).

Copy of the PyXMPP issue Jajcus/pyxmpp#23

Auth after registration fails

After successfully registering a new user pyxmpp.jabber.clientstream.LegacyClientStream incorrectly sets self.password to be an instance of pyxmpp.jabber.dataforms.Field when it should be a string. Looks like the '.value' is missing. Patch attached.

Copy of the PyXMPP issue Jajcus/pyxmpp#26

Optional attributes always being set in dataforms.Option and dataforms.Field

dataforms.Option.label and dataforms.Field.type are optional as per JEP-0004

dataforms.py always attaches these attributes when building the xml.

patch below:

{{{

Index: pyxmpp/jabber/dataforms.py

--- pyxmpp/jabber/dataforms.py (revision 661)
+++ pyxmpp/jabber/dataforms.py (working copy)
@@ -70,7 +70,8 @@
- xmlnode: libxml2.xmlNode
- doc: libxml2.xmlDoc"""
_unused = doc

  •    xmlnode.setProp("label", self.label.encode("utf-8"))
    
  •    if self.label is not None:
    
  •        xmlnode.setProp("label", self.label.encode("utf-8"))
     for value in self.values:
         xmlnode.newTextChild(xmlnode.ns(), "value", value.encode("utf-8"))
     return xmlnode
    
    @@ -259,7 +260,8 @@
    - doc: libxml2.xmlDoc"""
    if self.type is not None and self.type not in self.allowed_types:
    raise ValueError, "Invalid form field type: %r" % (self.type,)
  •    xmlnode.setProp("type", self.type)
    
  •    if self.type is not None:
    
  •        xmlnode.setProp("type", self.type)
     if not self.label is None:
         xmlnode.setProp("label", self.label)
     if not self.name is None:
    
    }}}

Copy of the PyXMPP issue Jajcus/pyxmpp#8

VCard does not escape semicolons per RFC 2426

{{{

from pyxmpp.jabber.vcard import VCard, VCardName
v = VCard('')
n = VCardName('N', '')
n.given = 'Christopher; a semi-colon and a sentence, too.'
v.content['N'] = n
v.as_xml().serialize()
'\nChristopher; a semi-colon and a sentence, too.\n'
xml = [c for c in v.as_xml().children][0] #list comprehension to compensate for \nChristopher; a semi-colon and a sentence, too.Christopher; a semi-colon and a sentence, too.\n'
v.rfc2426()
'begin:VCARD\r\nversion:3.0\r\nn:;Christopher; a semi-colon and a sentence, too.;;;\r\nend:VCARD\r\n'
v3 = VCard(v.rfc2426())
Traceback (most recent call last):
File "", line 1, in
File "C:\workspace\lib\pyxmpp\jabber\vcard.py", line 1363, in init
self.n = None
File "C:\workspace\lib\pyxmpp\jabber\vcard.py", line 1477, in from_rfc2426
continue
File "C:\workspace\lib\pyxmpp\jabber\vcard.py", line 1508, in _process_rfc2425_record
if params:
File "C:\workspace\lib\pyxmpp\jabber\vcard.py", line 303, in __init

n=n.next
ValueError: too many values to unpack
}}}

since the semicolons are not backslash escaped, nor unescaped, string values with ';' in them cannot be handled properly.

a regex which can be used to properly split strings with escaped semicolons using a negative lookbehind assertion:
{{{non_quoted_semicolon_re=re.compile(r'(?<!);')}}}

I'll append patches and such as I finalize my fixes.

Copy of the PyXMPP issue Jajcus/pyxmpp#21

In certain cases pyxmpp eats exceptions

xmlextra.endElement() eats exceptions, instead of letting them propagate.

While it's bad style to let exceptions get away from callbacks, it may happen and then errors don't get reported. In my case an unexpected UnicodeEncodeError from pyxmpp code itself wasn't caught in my code, wreaked some havoc and vanished without a trace. Not a pleasant thing to debug.

Relevant part of a stack from my case to illustrate the issue:

{{{
File "/home/karol/programowanie/pyxmpp/pyxmpp/xmlextra.py", line 214, in endElement
self._handler.stanza(self._doc, node1)
File "/home/karol/programowanie/pyxmpp/pyxmpp/streambase.py", line 401, in stanza
self._process_node(node)
File "/home/karol/programowanie/pyxmpp/pyxmpp/stream.py", line 107, in _process_node
StreamBase._process_node(self,xmlnode)
File "/home/karol/programowanie/pyxmpp/pyxmpp/streambase.py", line 710, in _process_node
self.process_stanza(stanza)
File "/home/karol/programowanie/pyxmpp/pyxmpp/stanzaprocessor.py", line 274, in process_stanza
if self.process_message(stanza):
File "/home/karol/programowanie/pyxmpp/pyxmpp/stanzaprocessor.py", line 209, in process_message
return self.__try_handlers(self._message_handlers,"normal",stanza)
File "/home/karol/programowanie/pyxmpp/pyxmpp/stanzaprocessor.py", line 185, in __try_handlers
response = handler(stanza)
File "/home/karol/programowanie/soc/tmp/jabberbot/xmppbot.py", line 372, in handle_message
response = self.handle_internal_command(sender, command)
File "/home/karol/programowanie/soc/tmp/jabberbot/xmppbot.py", line 402, in handle_internal_command
self.send_search_form(sender)
File "/home/karol/programowanie/soc/tmp/jabberbot/xmppbot.py", line 319, in send_search_form
message.add_content(form)
File "/home/karol/programowanie/pyxmpp/pyxmpp/stanza.py", line 303, in add_content
content.as_xml(parent = self.xmlnode, doc = common_doc)
File "/home/karol/programowanie/pyxmpp/pyxmpp/objects.py", line 91, in as_xml
self.complete_xml_element(xmlnode, doc1)
File "/home/karol/programowanie/pyxmpp/pyxmpp/jabber/dataforms.py", line 632, in complete_xml_element
xmlnode.newTextChild(ns, "title", self.title)
File "/usr/lib64/python2.3/site-packages/libxml2.py", line 3325, in newTextChild
ret = libxml2mod.xmlNewTextChild(self._o, ns__o, name, content)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u015b' in position 2: ordinal not in range(128)
}}}

Copy of the PyXMPP issue Jajcus/pyxmpp#14

ExpiringDictionary + StanzaProcessor timeout threadsafety [patch]

I needed thread-safety for timeout callbacks, to ensure that only one of the response/error/timeout callbacks can be called.

The patches are centered around the implementation of {{{dict.pop()}}} for the {{{ExpiringDictionary}}} and transactional removal from the dictionary before doing callbacks. This prevents another callback from being called while the first one is in progress.

patches attached.

Copy of the PyXMPP issue Jajcus/pyxmpp#31

Make it installable from cheeseshop.

I would like to simple include ''pyxmpp'' in my ''zc.buildout'' configs without defining the download URI in the ''dependency_links'' section. You guys already have a pypi account but do not provide a download link also your snapshot names seem to have no valid version string, could you change them to use svn revision numbers or something setuptools can understand?

Also would it be possible to include your dependencies in the ''install_requires'' section of the setup.py file? A patch for that is attached.

Copy of the PyXMPP issue Jajcus/pyxmpp#22

truncated XML sent to server

PyXMPP doesn't check the return code of socket.send (in streambase.py and streamtls.py) which could result in truncated data being sent to the server. See the documentation for socket.send: "Returns the number of bytes sent. Applications are responsible for checking that all data has been sent; if only some of the data was transmitted, the application needs to attempt delivery of the remaining data."

Copy of the PyXMPP issue Jajcus/pyxmpp#37

Incorrect bidirectional check (mispelling)

In the xmppstringprep.py file I've notice a probable bug in bidi_check function:
in the 231 and 233 lines the code assign 1 in has_l line, but the 231 lines should be assign this value to has_ral, I think.

Copy of the PyXMPP issue Jajcus/pyxmpp#19

Wrong handling of dataforms.Option "values" field?

According to XEP-004, Option elements can't have more than 1 element. pyxmpp uses "values" argument to Option constructor to create multiple elements, which has no use and is against the specification. Passing a single-element list containing a string is not intuitive and error prone. Passing a "vaa" string produces output like:

v a a

Copy of the PyXMPP issue Jajcus/pyxmpp#18

getting rosters error

When I connected to jabber.org server(ejabberd server), the pyxmpp library can not handle rosters list. my suggestion :
change file pyxmpp\stanzaprocessor.py line 112:
'' elif ( (fr==self.peer or fr==self.me)''
to:
''elif ( (fr==self.peer or fr==self.me or fr.bare() == self.me.bare())''

will fix the bug.

Copy of the PyXMPP issue Jajcus/pyxmpp#28

Python 3.2 support

PyXMPP2 should be also available for Python3.

There is still a problem with the DNSPython dependency (no official release for Python3), but this should not stop us.

The code will be developed for Python 2.7 with python3 in mind and converted using the 2to3 tool.

echobot.py example error line 99

line 99 of echobot.py in the examples has a coding error

to see the error send a message to the id the bot logs on as then logout
run the bot and it will fail on line 99

Note: line 99 has no %s to be filled in with the variable

code should be changed from:

  print u'Type: normal.' % (t,)

to
print u'Type: normal.',

Copy of the PyXMPP issue Jajcus/pyxmpp#4

StreamParseError: parsing finished with the standard ElementTree

Client stream crashes after the stream is closed on error by the remote party:

DEBUG:pyxmpp.tcp.in:IN: ''
DEBUG:pyxmpp.streambase:Passing element <Element '{urn:ietf:params:xml:ns:xmpp-sasl}failure' at 0x837a10c> to method <bound method StreamSASLHandler._process_sasl_failure of <pyxmpp2.streamsasl.StreamSASLHandler object at 0x836c66c>>
DEBUG:pyxmpp.streamsasl:SASL authentication failed: '<ns0:failure xmlns:ns0="urn:ietf:params:xml:ns:xmpp-sasl"><ns0:not-authorized />/ns0:failure'
DEBUG:pyxmpp.transport:TCPTransport.disconnect()
DEBUG:pyxmpp.tcp.out:OUT: '/stream:stream'
DEBUG:pyxmpp.transport: _set_state('closing')
DEBUG:pyxmpp.transport:handle_read()
DEBUG:pyxmpp.transport:tls socket read...
DEBUG:pyxmpp.tcp.in:IN: '/stream:stream'
Traceback (most recent call last):
File "./simple_send_message.py", line 21, in
send_message(your_jid, your_password, target_jid, message)
File "/home/users/jajcus/git/pyxmpp2/examples/pyxmpp2/simple.py", line 132, in send_message
handler.disconnect()
File "/home/users/jajcus/git/pyxmpp2/examples/pyxmpp2/simple.py", line 58, in disconnect
self.client.run(timeout = 2)
File "/home/users/jajcus/git/pyxmpp2/examples/pyxmpp2/client.py", line 149, in run
self.mainloop.loop(timeout)
File "/home/users/jajcus/git/pyxmpp2/examples/pyxmpp2/mainloop/base.py", line 90, in loop
self.loop_iteration(interval)
File "/home/users/jajcus/git/pyxmpp2/examples/pyxmpp2/mainloop/poll.py", line 142, in loop_iteration
self._handlers[fileno].handle_read()
File "/home/users/jajcus/git/pyxmpp2/examples/pyxmpp2/transport.py", line 693, in handle_read
self._feed_reader(data)
File "/home/users/jajcus/git/pyxmpp2/examples/pyxmpp2/transport.py", line 797, in _feed_reader
self._reader.feed(data)
File "/home/users/jajcus/git/pyxmpp2/examples/pyxmpp2/xmppparser.py", line 216, in feed
self.handler.stream_parse_error(unicode(err))
File "/home/users/jajcus/git/pyxmpp2/examples/pyxmpp2/streambase.py", line 378, in stream_parse_error
raise StreamParseError(descr)
pyxmpp2.exceptions.StreamParseError: parsing finished: line 1, column 412

XEP-0166 (Jingle)

Nice to have – Jingle support and related stuff for XMPP-based VoIP.

Message.make_error_response sets weird namespaces

{{{

!xml

@subj@ @msg@ darkk }}}

pyxmpp-based handler has following code:

{{{

!python

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:

{{{

!xml

darkk @msg@ @subj@ }}}

As far as I understand, subject and body have incorrect namespace (and psi ignores these body and subject).

Possible hackish workaround is to call
{{{

!python

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()

}}}

Copy of the PyXMPP issue Jajcus/pyxmpp#24

plain tls connections without starttls

Hi there,

I've done a small patch to pyxmpp-1.0.0.s20061212 to be able to open connections to jabber servers which use tls right from the beginning on port 5223 instead of doing starttls on port 5222. It's not as neat as I'd like it to be but it seems to work. :)

Hope it's of any use to you.

Copy of the PyXMPP issue Jajcus/pyxmpp#10

VCardImage parsing failures

[source:trunk/pyxmpp/jabber/vcard.py##L394 line 394 of vcard.py] fails when there is no key {{{"value"}}} in the {{{rfc2425parameters}}} dict object. The current code below:
{{{
if rfc2425parameters.get("value").lower()=="uri":
}}}
when {{{"value"}}} does not exist in the dictionary, {{{get("value")}}} returns {{{None}}}, resulting in {{{None.lower()}}} which finally throws an exception:
{{{
AttributeError: 'NoneType' object has no attribute 'lower'
}}}
This is caused by the default return value from get, which itself defaults to {{{None}}}. My fix is to include a default value of empty string:

{{{
if rfc2425parameters.get("value", '').lower()=="uri":

}}}

I also had some trouble with not all of the attributes being initialized when parsing from !rfc2425 versions, my fix is to move the initialization with {{{None}}} out of the if statement on [source:trunk/pyxmpp/jabber/vcard.py##L370 line 370 of vcard.py].
{{{
if isinstance(value,libxml2.xmlNode):
self.uri,self.type,self.image=[None]_3
}}}
becomes
{{{
self.uri,self.type,self.image=[None]_3
if isinstance(value,libxml2.xmlNode):
}}}

Copy of the PyXMPP issue Jajcus/pyxmpp#13

trailing whitespace during sasl with jabberd2

on client connect with pyxmpp to a jabberd2 server, a "no nonce" error ococurs.

this is because the parser returns " charset" " user" and so one...
the simple strimcompare fails.
I add a small strip.
I dont know if this breaks something: but it works.

I already build at the ComponentStream...
(with an very old version I hacked component 2.0 support in)
(but with current this doenst work - i will expect this later)

patch:

Index: pyxmpp/sasl/digest_md5.py

--- pyxmpp/sasl/digest_md5.py (Revision 677)
+++ pyxmpp/sasl/digest_md5.py (Arbeitskopie)
@@ -254,6 +254,7 @@
var=m.group("var")
val=m.group("val")
self.__logger.debug("%r: %r" % (var,val))

  •       var=var.lstrip(' ');
         if var=="realm":
             realms.append(_unquote(val))
         elif var=="nonce":
    

Questions(jabber*G): white at addoma.de

Copy of the PyXMPP issue Jajcus/pyxmpp#25

Example script echobot.py fails on "normal" message type

Forwarded message from Debian bug #530498

From: Tim Retout [email protected]
To: Debian Bug Tracking System [email protected]
Subject: python-pyxmpp-doc: echobot.py fails on "normal" message type
Date: Mon, 25 May 2009 08:34:59 +0100

Package: python-pyxmpp-doc
Version: 1.0.1-1
Severity: minor
Tags: patch

There's a small problem in the echobot.py example script when the
received message is the "normal" type. This is the end of the stack
trace:

File "echobot.py", line 75, in message
print u'Type: "normal".' % (t,)
TypeError: not all arguments converted during string formatting

Here is a fix:

--- examples/echobot.py.orig 2009-05-25 08:24:16.000000000 +0100
+++ examples/echobot.py 2009-05-25 08:25:17.000000000 +0100
@@ -72,7 +72,7 @@
if t:
print u'Type: "%s".' % (t,)
else:

  •        print u'Type: "normal".' % (t,)
    
  •        print u'Type: "normal".'
     if stanza.get_type()=="headline":
         # 'headline' messages should never be replied to
         return True
    

Copy of the PyXMPP issue Jajcus/pyxmpp#36

Patch for SASL External authentication

Hi,

I'm working on jabberd2 to implement c2s SASL external authentication based on TLS certificates.

I've used pyxmpp as the testing library for the connections and I can only say it works :)

Implemented stuff:

  1. Fixed deprecated m2crypto client certificate stuff
  2. Added SASL external authenticator
  3. Modified bits of code to make it work.

The following stadards were used:

  1. RFC3920bis (http://mail.jabber.org/pipermail/standards/2008-June/018939.html)
  2. XEP-0178 (http://xmpp.org/extensions/xep-0178.html#c2s)

The following patch is made against pyxmpp-1.0.1 release tarball. I'm also attaching a testing script which successfully connects to my modified jabberd2 server (patches to that server will be posted soon).

Copy of the PyXMPP issue Jajcus/pyxmpp#34

Finish the PyXMPP -> PyXMPP 2 refactorization

Still not rewritten (specific issue):

./pyxmpp2/cache.py
./pyxmpp2/roster.py (issue #42)
./pyxmpp2/ext/component.py
./pyxmpp2/ext/dataforms.py
./pyxmpp2/ext/delay.py
./pyxmpp2/ext/disco.py (issue #43)
./pyxmpp2/ext/legacyauth.py
./pyxmpp2/ext/register.py
./pyxmpp2/ext/vcard.py

Wrong JID check in __roster_push()

Hi,

I'm writing a simple client and I'm using an account on jabster.pl for testing. It seems however that check for the source JID in Client._roster_push is a little bit overzelous. The problem appears when one wants to connect to a specified resource name.

It raises ClientError exception which causes the roster push to fail and crashes the application (yes, I know it can be catched around loop_iter). The if check should look if the roster doesn't come from a substring of the JID or something.

The backtrace:
2009-03-03 21:57:38,302 DEBUG [streambase] IN: ""
2009-03-03 21:57:38,306 DEBUG [streamtls] OUT: '<default1:query xmlns="jabber:iq:roster" xmlns:default1="jabber:iq:roster"><default1:item subscription="none" jid="[email protected]"/>/default1:query'
Traceback (most recent call last):
File "/home/neuro/workspace/smoa-dev-node/src/smoa-dev-node.py", line 125, in
main()
File "/home/neuro/workspace/smoa-dev-node/src/smoa-dev-node.py", line 63, in main
core_obj.loop()
File "/home/neuro/workspace/smoa-dev-node/src/core/core.py", line 97, in loop
self.tmanager.iter_all()
File "/home/neuro/workspace/smoa-dev-node/src/core/transportmanager.py", line 45, in iter_all
obj.iter()
File "/home/neuro/workspace/smoa-dev-node/src/transport/xmpp.py", line 61, in iter
self._client.stream.loop_iter(1)
File "usr/lib/python2.6/site-packages/pyxmpp/streambase.py", line 598, in loop_iter
File "usr/lib/python2.6/site-packages/pyxmpp/streambase.py", line 616, in _loop_iter
File "usr/lib/python2.6/site-packages/pyxmpp/streamtls.py", line 179, in _process
File "usr/lib/python2.6/site-packages/pyxmpp/streambase.py", line 637, in _process
File "usr/lib/python2.6/site-packages/pyxmpp/streamtls.py", line 174, in _read
File "usr/lib/python2.6/site-packages/pyxmpp/streambase.py", line 661, in _read
File "usr/lib/python2.6/site-packages/pyxmpp/streambase.py", line 677, in _feed_reader
File "usr/lib/python2.6/site-packages/pyxmpp/xmlextra.py", line 537, in feed
File "usr/lib/python2.6/site-packages/pyxmpp/xmlextra.py", line 57, in _stanza
File "usr/lib/python2.6/site-packages/pyxmpp/streambase.py", line 401, in stanza
File "usr/lib/python2.6/site-packages/pyxmpp/stream.py", line 107, in _process_node
File "usr/lib/python2.6/site-packages/pyxmpp/streambase.py", line 710, in _process_node
File "usr/lib/python2.6/site-packages/pyxmpp/stanzaprocessor.py", line 271, in process_stanza
File "usr/lib/python2.6/site-packages/pyxmpp/stanzaprocessor.py", line 141, in process_iq
File "usr/lib/python2.6/site-packages/pyxmpp/client.py", line 346, in __roster_push
pyxmpp.exceptions.ClientError: Got roster update from wrong source

Copy of the PyXMPP issue Jajcus/pyxmpp#30

pyxmpp.__revision__ doesn't get updated with each change

pyxmpp.revision is constructed using a $Id$ keyword in {{{pyxmpp/init.py}}}, but in Subversion each file may have a distinct revision. Therefore, revision of {{{init.py}}} doesn't reflect the revision of repository as a whole. This makes it impossible to get the exact revision number (useful when API has been changed and we need to know which version is supported).

Copy of the PyXMPP issue Jajcus/pyxmpp#17

Language support for stanza content

Currently language is only negotiated and set for the stream root. In XMPP any XML element containing readable text can have a language specified and usually can be provided in many language versions. Details are described in RFC 6120.

In particular the following elements can have alternate languages:

  • Stream error and stanza error elements
  • Message stanza and
  • Presence stanza

All these should be handled with the same API, probably using some 'multi-language string' type instead of plain unicode for appropriate properties.

default tls certificate verify function broken

When using the default tls certificate verify function, the following exception appears:

Traceback (most recent call last):
File "/usr/lib64/python2.4/site-packages/pyxmpp/streamtls.py", line 376, in tls_default_verify_callback
if ok and not tls_is_certificate_valid(store_context):

It is easily fixed by adding the missing "self." in front of tls_is_certificate_valid on line 376 in streamtls.py.

I experienced the problem with pyxmpp-1.0.0.s20061212.

Copy of the PyXMPP issue Jajcus/pyxmpp#9

Patch for SASL External authentication

Hi,

I'm working on jabberd2 to implement c2s SASL external authentication based on TLS certificates.

I've used pyxmpp as the testing library for the connections and I can only say it works :)

Implemented stuff:[[BR]]

  1. Fixed deprecated m2crypto client certificate stuff[[BR]]
  2. Added SASL external authenticator[[BR]]
  3. Modified bits of code to make it work.[[BR]]

The following stadards were used:[[BR]]

  1. RFC3920bis (http://mail.jabber.org/pipermail/standards/2008-June/018939.html) [[BR]]
  2. XEP-0178 (http://xmpp.org/extensions/xep-0178.html#c2s)

The following patch is made against pyxmpp-1.0.1 release tarball. I'm also attaching a testing script which successfully connects to my modified jabberd2 server (patches to that server will be posted soon).

Copy of the PyXMPP issue Jajcus/pyxmpp#35

roster.remove_item not compliant

when using function roster.add_item:

  • a string jid
  • a roster item

may be passed. instead, when using function roster.remove_item:

  • only a JID object can be passed.

=> roster.remove_item should comply and accept:

  • a string jid or
  • a roster item.

r.

Copy of the PyXMPP issue Jajcus/pyxmpp#20

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.