fritzy / SleekXMPP

Python 2.6+/3.1+ XMPP Library
http://groups.google.com/group/sleekxmpp-discussion
Other
1.1k stars 299 forks source link

case insensitive for JID node #269

Closed stephanlascar closed 10 years ago

stephanlascar commented 10 years ago

Hi,

Between 1.0 and 1.1.11, JID seems to be lowered case.

If I a receive like: <presence to="someone@domain.com" from="James@domain.com"></presence>, dumping presence['from'] of sleekxmpp.stanza.presence.Presence gives James@domain.com in version 1.0 whereas in version 1.1.11, it gives james@domain.com.

According to the XEP-0029 (http://xmpp.org/extensions/xep-0029.html), JIDs node allows uppercase characters.

Sleek should not lowercase node from JIDs.

The following test fails with 1.1.11:

# -*- coding: utf-8 -*-
from sleekxmpp import JID
from nose_asserts import assert_equal

class SleekTest(object):

    def test_jid_case(self):
        jid = JID('Admin@orange.com/resource')
        assert_equal('Admin', jid.node)
legastero commented 10 years ago

Note that XEP-0029 was retracted, and that RFC 6122 is what you want to reference.

The issue is that ADMIN@orange.com is actually the same JID as admin@orange.com.

There is a required normalization process defined in RFC 6122 that makes it possible to perform consistent comparisons between JIDs, particularly ones using Unicode characters that can be created multiple ways.

Sleek now provides the normalized version of the JID so that you can reliably compare JIDs at will without worrying about equivalent JID "spellings."

stephanlascar commented 10 years ago

Thanks for your help !