Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
dtjoa #1
Member since Jul 2012 · 39 posts
Group memberships: Members
Show profile · Link to this post
Subject: XmppClient.MessageFilter() seems not using BareJidComparer()
Alex,

I call XmppClient.MessageFilter.Add(userJid, new Matrix.BareJidComparer(), MyMessageHandler).
UserJid = "TEST235@svr02001.uc.test.lab.com"

It seemed that MyMessageHandler() was not triggered. Only my OnMessage() handler that I attached to XmppClient.OnMessage event was triggered. I thought BareJidComparer() will compare Bare jid case-insensitive. I am running Matrix.dll version 1.5.1.2.
If I change the userJid to lowercase, I don't see the problem.

Below some trace:

2012-09-18 15:53:46,625 [10] INFO  MyXmpp.IMControl - Add IM message notification(TEST235@svr02001.uc.test.lab.com)
2012-09-18 15:53:49,828 [10] INFO  MyXmpp.XmppPresenter - SND: <message type="chat" to="TEST235@svr02001.uc.test.lab.com" xmlns="jabber:client">
  <body>test message</body>
</message>
2012-09-18 15:53:55,562 [10] INFO  MyXmpp.XmppPresenter - RCV: <message xmlns="jabber:client" from="test235@svr02001.uc.test.lab.com/bora-bora" to="test216@svr02001.uc.test.lab.com" type="chat">
  <body>hello</body>
</message>
2012-09-18 15:53:55,562 [10] INFO  MyXmpp.XmppPresenter - OnMessage
Avatar
Alex #2
Member since Feb 2003 · 4308 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
TEST235@svr02001.uc.test.lab.com is not a "correct" Jid because in XMPP StringPrep must be applied to all the parts of a Jid.
For ASCII characters stringprep is just lower case for the node and domain part, but for other codepages its a very complex task. This complexity is the reason why MatriX does not automatically run each Jid through stringprep again before using it. Because this would costs lots of CPU. MatriX also assumes that all Jids which you get from the server are correct and prepared accodring to the stringprep profiles.

The Jid class can apply the stringPrep for you:

  1. var jid = new Jid("TEST235@svr02001.uc.test.lab.com", true);
  2. // result will be test235@svr02001.uc.test.lab.com

See also SetUser, SetServer and SetResource.

I suggest to stringprep all user input before you use it. Also the credentials before you login.

This stringprepping is a very complex topic in XMPP. So I am also open to any feedback. I can also add teh ability to stringprep everything in the compareres, but this can costs lots of CPU when you use it a lot, or would require some internal stringPrep cache.

Alex
Avatar
dtjoa #3
Member since Jul 2012 · 39 posts
Group memberships: Members
Show profile · Link to this post
Alex,

Thanks for the explanation. I'll update my codes.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS