fix(HtmlParser): check if hashtag has text

Fixes a crash, where the text of an hashtag was empty, leading to an oob
string access.
This commit is contained in:
FineFindus 2024-08-31 10:44:53 +02:00
parent c2e6280a18
commit 7fa079e362
No known key found for this signature in database
GPG key ID: 64873EE210FF8E6B

View file

@ -140,7 +140,7 @@ public class HtmlParser{
String href=el.attr("href"); String href=el.attr("href");
LinkSpan.Type linkType; LinkSpan.Type linkType;
String text=el.text(); 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 // MOSHIDON: we have slightly refactored this so that the hashtags properly work in akkoma
// TODO: upstream this // TODO: upstream this
linkType=LinkSpan.Type.HASHTAG; linkType=LinkSpan.Type.HASHTAG;