aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/utils
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-05-05 20:44:05 +0200
committerChristian Schneppe <christian@pix-art.de>2018-05-05 20:44:05 +0200
commit0446624c51942118e74fbba93d40d83a9856723d (patch)
tree60faffcc7994f3b9bc05644e6129b31f5aa620f1 /src/main/java/de/pixart/messenger/utils
parentf37b1410e17ac8400c8b87a09b81b8af50c74e9d (diff)
filter sequences of more than 3 ltr-rtl
Diffstat (limited to 'src/main/java/de/pixart/messenger/utils')
-rw-r--r--src/main/java/de/pixart/messenger/utils/MessageUtils.java8
-rw-r--r--src/main/java/de/pixart/messenger/utils/UIHelper.java2
2 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/MessageUtils.java b/src/main/java/de/pixart/messenger/utils/MessageUtils.java
index 8a3cdb707..78be415f7 100644
--- a/src/main/java/de/pixart/messenger/utils/MessageUtils.java
+++ b/src/main/java/de/pixart/messenger/utils/MessageUtils.java
@@ -31,11 +31,15 @@ package de.pixart.messenger.utils;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.regex.Pattern;
import de.pixart.messenger.entities.Message;
import de.pixart.messenger.http.AesGcmURLStreamHandler;
public class MessageUtils {
+
+ private static final Pattern LTR_RTL = Pattern.compile("(\\u200E[^\\u200F]*\\u200F){3,}");
+ private static final String EMPTY_STRING = "";
public static String prepareQuote(Message message) {
final StringBuilder builder = new StringBuilder();
final String body = message.getMergedBody().toString();
@@ -79,4 +83,8 @@ public class MessageUtils {
return false;
}
}
+
+ public static String filterLtrRtl(String body) {
+ return LTR_RTL.matcher(body).replaceFirst(EMPTY_STRING);
+ }
} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/utils/UIHelper.java b/src/main/java/de/pixart/messenger/utils/UIHelper.java
index dc15d41e4..e167e8c84 100644
--- a/src/main/java/de/pixart/messenger/utils/UIHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/UIHelper.java
@@ -278,7 +278,7 @@ public class UIHelper {
} else if (message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) {
return new Pair<>(getFileDescriptionString(context, message), true);
} else {
- final String body = message.getBody();
+ final String body = MessageUtils.filterLtrRtl(message.getBody());
if (body.startsWith(Message.ME_COMMAND)) {
return new Pair<>(body.replaceAll("^" + Message.ME_COMMAND, UIHelper.getMessageDisplayName(message)), false);
} else if (message.isGeoUri()) {