diff options
author | Alex Clayton <alex.clayton@isode.com> | 2016-03-21 15:41:42 (GMT) |
---|---|---|
committer | Alex Clayton <alex.clayton@isode.com> | 2016-03-22 11:24:06 (GMT) |
commit | 0ec7a2d8ab803b0e2df2c616f61d2b69b042561f (patch) | |
tree | c4c03f68cc001294a304ed23c923c6b8c37d0cb2 /src/com/isode | |
parent | aa5444b24c46f1e3a83682a59e71c780e2523160 (diff) | |
download | stroke-0ec7a2d8ab803b0e2df2c616f61d2b69b042561f.zip stroke-0ec7a2d8ab803b0e2df2c616f61d2b69b042561f.tar.bz2 |
Don't allow JIDs with explicitly empty resources
As per swiften patch of same name
(6159c580884583bad0e17d4e96ea9ffc7e0be29a).
A JID may have no resource, but may not have an empty resource. Mark
such JIDs as invalid.
Test-information: New unit test passes.
Change-Id: I66ec7810ac29cb3963470b08f0d9f4901d2307f3
Diffstat (limited to 'src/com/isode')
-rw-r--r-- | src/com/isode/stroke/jid/JID.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/com/isode/stroke/jid/JID.java b/src/com/isode/stroke/jid/JID.java index 59eef52..8b62ca1 100644 --- a/src/com/isode/stroke/jid/JID.java +++ b/src/com/isode/stroke/jid/JID.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2012, Isode Limited, London, England. + * Copyright (c) 2010-2016, Isode Limited, London, England. * All rights reserved. */ /* @@ -14,13 +14,13 @@ package com.isode.stroke.jid; -import com.isode.stroke.idn.ICUConverter; -import com.isode.stroke.idn.IDNConverter; -import com.ibm.icu.text.StringPrepParseException; -import com.isode.stroke.base.NotNull; import java.util.Arrays; import java.util.List; +import com.isode.stroke.base.NotNull; +import com.isode.stroke.idn.ICUConverter; +import com.isode.stroke.idn.IDNConverter; + /** * JID helper. * @@ -147,6 +147,9 @@ public class JID implements Comparable<JID> { NotNull.exceptIfNull(domain, "domain"); valid_ = true; hasResource_ = (resource != null); + if (hasResource_ && resource.isEmpty()) { + valid_ = false; + } nameprepAndSetComponents(node, domain, resource); } |