Skip to content

Commit 9d64edf

Browse files
authored
Merge pull request #956 from vector-im/feature/bma/fixAlternateTextCrash
alternateText can't be an empty string. #955
2 parents 61a3705 + b2394b6 commit 9d64edf

File tree

1 file changed

+13
-3
lines changed
  • features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html

1 file changed

+13
-3
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/html/HtmlDocument.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,17 +544,27 @@ private fun AnnotatedString.Builder.appendLink(link: Element) {
544544
pop()
545545
}
546546
is PermalinkData.RoomEmailInviteLink -> {
547-
appendInlineContent(CHIP_ID, link.ownText())
547+
safeAppendInlineContent(CHIP_ID, link.ownText())
548548
}
549549
is PermalinkData.RoomLink -> {
550-
appendInlineContent(CHIP_ID, link.ownText())
550+
safeAppendInlineContent(CHIP_ID, link.ownText())
551551
}
552552
is PermalinkData.UserLink -> {
553-
appendInlineContent(CHIP_ID, link.ownText())
553+
safeAppendInlineContent(CHIP_ID, link.ownText())
554554
}
555555
}
556556
}
557557

558+
fun AnnotatedString.Builder.safeAppendInlineContent(chipId: String, ownText: String) {
559+
if (ownText.isEmpty()) {
560+
// alternateText cannot be empty and default parameter value is private,
561+
// so just omit the second param here.
562+
appendInlineContent(chipId)
563+
} else {
564+
appendInlineContent(chipId, ownText)
565+
}
566+
}
567+
558568
@Composable
559569
private fun HtmlText(
560570
text: AnnotatedString,

0 commit comments

Comments
 (0)