aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2017-12-05 19:02:23 +0100
committerDaniel Gultsch <daniel@gultsch.de>2017-12-05 19:02:23 +0100
commit0e6d3db92622cb1e6bc5e9b89ae6089a5433cc70 (patch)
tree602bdb8c2db958044b37c54074f18bc510b3c1c0
parent5885bc7f252631a5f41ed8dd4c8d354dbfeb922c (diff)
Do not show xmpp uris as links that have invalid jids
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index af1bd21..b93931d 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -76,6 +76,7 @@ import eu.siacs.conversations.utils.GeoHelper;
import eu.siacs.conversations.utils.Patterns;
import eu.siacs.conversations.utils.StylingHelper;
import eu.siacs.conversations.utils.UIHelper;
+import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xmpp.mam.MamReference;
public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextView.CopyHandler {
@@ -114,6 +115,14 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
};
+ private static final Linkify.MatchFilter XMPPURI_MATCH_FILTER = new Linkify.MatchFilter() {
+ @Override
+ public boolean acceptMatch(CharSequence s, int start, int end) {
+ XmppUri uri = new XmppUri(s.subSequence(start,end).toString());
+ return uri.isJidValid();
+ }
+ };
+
private final ConversationActivity activity;
private DisplayMetrics metrics;
@@ -491,7 +500,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
StylingHelper.format(body, viewHolder.messageBody.getCurrentTextColor());
- Linkify.addLinks(body, XMPP_PATTERN, "xmpp");
+ Linkify.addLinks(body, XMPP_PATTERN, "xmpp", XMPPURI_MATCH_FILTER, null);
Linkify.addLinks(body, Patterns.AUTOLINK_WEB_URL, "http", WEBURL_MATCH_FILTER, WEBURL_TRANSFORM_FILTER);
Linkify.addLinks(body, GeoHelper.GEO_URI, "geo");
FixedURLSpan.fix(body);