diff options
author | Andreas Straub <andy@strb.org> | 2015-05-14 15:25:52 +0200 |
---|---|---|
committer | Andreas Straub <andy@strb.org> | 2015-05-14 15:52:55 +0200 |
commit | b69ee7125d49493bea86c6e3095f1236ad895980 (patch) | |
tree | cf1b5ceb0d1a6c2a45c56c255614cc1d73ccdbf6 /src/main/java/eu/siacs/conversations/xmpp/jid | |
parent | 8dfa701043d6e442f24edeb4fec48e9d07377a90 (diff) |
Force Nameprepping of JID domain parts
The IDN.toAscii()/IDN.toUnicode() family only namepreps the original
domain passed to it if it contained non-ASCII characters. This means
that for all-ASCII domains, no canonicalization is performed, which
leads to issues like case-sensitivity. This workaround explicitly
namepreps domain parts before calling IDN.toAscii() on them, in order to
get a canonicalized representation (most notably, case invariance). A
basic DB migration is also included.
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xmpp/jid')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java | 13 |
1 files changed, 10 insertions, 3 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 295e067a6..f989c0c25 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jid/Jid.java @@ -130,12 +130,19 @@ public final class Jid { if (resourcepart.isEmpty() || resourcepart.length() > 1023) { throw new InvalidJidException(InvalidJidException.INVALID_PART_LENGTH); } - dp = IDN.toUnicode(jid.substring(domainpartStart, slashLoc), IDN.USE_STD3_ASCII_RULES); + try { + dp = IDN.toUnicode(Stringprep.nameprep(jid.substring(domainpartStart, slashLoc)), IDN.USE_STD3_ASCII_RULES); + } catch (final StringprepException e) { + throw new InvalidJidException(InvalidJidException.STRINGPREP_FAIL, e); + } finaljid = finaljid + dp + "/" + rp; } else { resourcepart = ""; - dp = IDN.toUnicode(jid.substring(domainpartStart, jid.length()), - IDN.USE_STD3_ASCII_RULES); + try{ + dp = IDN.toUnicode(Stringprep.nameprep(jid.substring(domainpartStart, jid.length())), IDN.USE_STD3_ASCII_RULES); + } catch (final StringprepException e) { + throw new InvalidJidException(InvalidJidException.STRINGPREP_FAIL, e); + } finaljid = finaljid + dp; } |