Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
don't break custom emoji in pronouns
Browse files Browse the repository at this point in the history
  • Loading branch information
sk22 committed Oct 16, 2023
1 parent fc09514 commit 92d7ae6
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 92d7ae6

Please sign in to comment.