From 92d7ae67ef76490f3af5a6a0c0e1d3d84a02c75b Mon Sep 17 00:00:00 2001 From: sk Date: Tue, 17 Oct 2023 00:38:27 +0200 Subject: [PATCH] don't break custom emoji in pronouns --- .../java/org/joinmastodon/android/ui/utils/UiUtils.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 2fbce45efd..b9a7901d84 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -1700,14 +1700,17 @@ private static String extractPronounsFromField(String localizedPronouns, Account Matcher matcher=trimPronouns.matcher(text); if(!matcher.find()) return null; - String matched=matcher.group(1); + String pronouns=matcher.group(1); // crude fix to allow for pronouns like "it(/she)" int missingClosingParens=0; - for(char c : matched.toCharArray()){ + for(char c : pronouns.toCharArray()){ if(c=='(') missingClosingParens++; if(c==')') missingClosingParens--; } - return matched+")".repeat(Math.max(0, missingClosingParens)); + pronouns+=")".repeat(Math.max(0, missingClosingParens)); + // if ends with an un-closed custom emoji + if(pronouns.matches("^.*\\s+:[a-zA-Z_]+$")) pronouns+=':'; + return pronouns; } // https://stackoverflow.com/questions/9475589/how-to-get-string-from-different-locales-in-android