aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Whited <sam@samwhited.com>2014-12-02 09:16:09 -0500
committerSam Whited <sam@samwhited.com>2014-12-02 09:16:09 -0500
commit3fc834c0674960b416d9adb270ed29ce500b2379 (patch)
tree646f052b92f201b2b63609e91193c67bd886898c
parent59402da60d9d99f17a9635364945c79014385e37 (diff)
Fix RFC 6122 implementation
JID resourceparts should be able to contain "@" and "/" characters
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java
index ebf8a6ed..c156b8b6 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java
@@ -68,8 +68,9 @@ public final class Jid {
if (jid.isEmpty() || jid.length() > 3071) {
throw new InvalidJidException(InvalidJidException.INVALID_LENGTH);
}
- if (atCount > 1 || slashCount > 1 ||
- jid.startsWith("@") || jid.endsWith("@") ||
+
+ // Go ahead and check if the localpart or resourcepart is empty.
+ if (jid.startsWith("@") || jid.endsWith("@") ||
jid.startsWith("/") || jid.endsWith("/")) {
throw new InvalidJidException(InvalidJidException.INVALID_CHARACTER);
}
@@ -77,7 +78,7 @@ public final class Jid {
String finaljid;
final int domainpartStart;
- if (atCount == 1) {
+ if (atCount >= 1) {
final int atLoc = jid.indexOf("@");
final String lp = jid.substring(0, atLoc);
try {
@@ -97,7 +98,7 @@ public final class Jid {
}
final String dp;
- if (slashCount == 1) {
+ if (slashCount >= 1) {
final int slashLoc = jid.indexOf("/");
final String rp = jid.substring(slashLoc + 1, jid.length());
try {