Skip to content

Commit

Permalink
feat(StatusDisplayItem/Quote): hide non-official quote mentions
Browse files Browse the repository at this point in the history
Hides the URL, with optional 'RE:' prefix and whitespace, that is used to construct non-official quotes.
  • Loading branch information
FineFindus committed Jul 6, 2024
1 parent 5fd2e32 commit ff90e21
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public abstract class StatusDisplayItem{
public static final int FLAG_NO_MEDIA_PREVIEW=1 << 8;


private final static Pattern QUOTE_MENTION_PATTERN=Pattern.compile("(?:<p>)?\\s?(?:RE:\\s?)?<a href=\"https:\\/\\/[^\"]+\"[^>]*><span class=\"invisible\">https:\\/\\/<\\/span><span class=\"ellipsis\">[^<]+<\\/span><span class=\"invisible\">[^<]+<\\/span><\\/a>(?:<\\/p>)?$");
private final static Pattern QUOTE_PATTERN=Pattern.compile("[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)");

public void setAncestryInfo(
Expand Down Expand Up @@ -274,6 +275,14 @@ public static ArrayList<StatusDisplayItem> buildItems(BaseStatusListFragment<?>
int quoteInlineIndex=statusForContent.content.lastIndexOf("<span class=\"quote-inline\"><br/><br/>RE:");
if(quoteInlineIndex!=-1)
statusForContent.content=statusForContent.content.substring(0, quoteInlineIndex);
else {
// hide non-official quote patters
Matcher matcher=QUOTE_MENTION_PATTERN.matcher(status.content);
if(matcher.find()){
String quoteMention=matcher.group();
statusForContent.content=statusForContent.content.replace(quoteMention, "");
}
}
}

boolean hasSpoiler=!TextUtils.isEmpty(statusForContent.spoilerText);
Expand Down

0 comments on commit ff90e21

Please sign in to comment.