JID constructor throws StringIndexOutOfBoundsException for nodes with slashes

Seen with tinder 1.2.1, but seems to exist with 1.2.2 as well.

Consider

new JID(“a/@b”);

–>

java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.lang.String.substring(String.java:1937)
at org.xmpp.packet.JID.getParts(JID.java:604)
at org.xmpp.packet.JID.(JID.java:468)

Hi Andreas,

an InvalidJID exception may be indeed much better. Actually a “/” must be escaped as “\2f” in the node identifier as described in http://xmpp.org/extensions/xep-0106.html.

LG

Actually, this appears to be a valid JID (provided that one-character domain parts are allowed - I assume they are)

JID Portion
Value
node
(none)
domain
a
resource
@b

1 Like

I’ve reported this bug as TINDER-47.

Hi Guus,

you’re rigth. So Tinder should process this JID properly without exception.

LG

PS: As far as I can tell it does not matter how long “a” and “b” are.

PPS: I wonder where an expection will be thrown when “a” or “b” are longer than 1024 bytes.

I’ve added a number of tests that check for variations of this problem. You can find the unit test class here: http://fisheye.igniterealtime.org/browse/tinder/trunk/src/test/java/org/xmpp/pac ket/JIDDelimiterCharsTest.java?r=HEAD

There are other tests in that same package that check for size of JID parts (by the way: 1023 bytes are allowable, 1024 not)

fixed in svn

Yeah, thanks a lot!

The formulation “nodes with slashes” turned out to be rather misleading, I am sorry for that.