From d405a0d04b13e21fd4f490a4edce868bd7706c78 Mon Sep 17 00:00:00 2001 From: Phil Cappelli <150719757+phil-livefront@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:24:35 -0500 Subject: [PATCH] PM-15976 - App crashes when non-english language user tries to create account (#4460) --- .../java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt index 5ec407b4d7..4efcade16a 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt @@ -199,6 +199,12 @@ fun createClickableAnnotatedString( mainString.lastIndexOf(text, ignoreCase = true) } } + + // Skip adding the link if the text to highlight is not found in the main string. + // This can happen if the highlighted text is correctly translated, but the main string + // is not yet translated, causing the startIndex to be -1. + if (startIndex < 0) continue + val endIndex = startIndex + highlight.textToHighlight.length val link = LinkAnnotation.Clickable( tag = highlight.textToHighlight,