From 7fa079e362653b6c84f906635264e7597b47b5cd Mon Sep 17 00:00:00 2001 From: FineFindus Date: Sat, 31 Aug 2024 10:44:53 +0200 Subject: [PATCH] fix(HtmlParser): check if hashtag has text Fixes a crash, where the text of an hashtag was empty, leading to an oob string access. --- .../main/java/org/joinmastodon/android/ui/text/HtmlParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java index 9d679db334..9698d911d7 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/text/HtmlParser.java @@ -140,7 +140,7 @@ public void head(@NonNull Node node, int depth){ String href=el.attr("href"); LinkSpan.Type linkType; String text=el.text(); - if(el.hasClass("hashtag") || text.startsWith("#")){ + if(!TextUtils.isEmpty(text) && (el.hasClass("hashtag") || text.startsWith("#"))){ // MOSHIDON: we have slightly refactored this so that the hashtags properly work in akkoma // TODO: upstream this linkType=LinkSpan.Type.HASHTAG;