From 393d2990f0824a8692e25065c181dfdaf01a160f Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 15 Nov 2022 18:02:49 +0100 Subject: [PATCH] Fix issue #403 - Freezes --- app/src/main/java/app/fedilab/android/helper/Helper.java | 5 +++++ .../java/app/fedilab/android/helper/SpannableHelper.java | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 4dd4da6c..3f74cd0d 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -340,6 +340,11 @@ public class Helper { Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); + public static final Pattern urlPatternSimple = Pattern.compile( + "https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)", + + Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL); + public static final Pattern aLink = Pattern.compile("]*(((?!"); public static final Pattern imgPattern = Pattern.compile("]*src=\"([^\"]+)\"[^>]*>"); diff --git a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java index 20a2857c..f94a7576 100644 --- a/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/SpannableHelper.java @@ -18,6 +18,7 @@ package app.fedilab.android.helper; import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.helper.Helper.USER_AGENT; import static app.fedilab.android.helper.Helper.urlPattern; +import static app.fedilab.android.helper.Helper.urlPatternSimple; import static app.fedilab.android.helper.ThemeHelper.linkColor; import android.content.ClipData; @@ -190,7 +191,7 @@ public class SpannableHelper { private static void linkify(Context context, SpannableStringBuilder content, HashMap urlDetails) { //--- URLs ---- - Matcher matcherLink = urlPattern.matcher(content); + Matcher matcherLink = urlPatternSimple.matcher(content); int offSetTruncate = 0;