From bdf7f329c13599850945a0ff467fc279a2d06d3d Mon Sep 17 00:00:00 2001 From: hayaksi1 <193020925+hayaksi1@users.noreply.github.com> Date: Sun, 9 Aug 2026 14:34:39 +0300 Subject: [PATCH] Build the bidi isolate characters from their code points Android lint rejects the literal U+2068 and U+2069 characters embedded in the string template with BidiSpoofing, "String contains misleading Unicode bidirectional text", which fails the lint task for the module. Naming the two code points and building the characters from them produces the same string and leaves no invisible characters in the source. --- .../android/libraries/eventformatter/impl/PrefixWith.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/eventformatter/impl/src/main/kotlin/io/element/android/libraries/eventformatter/impl/PrefixWith.kt b/libraries/eventformatter/impl/src/main/kotlin/io/element/android/libraries/eventformatter/impl/PrefixWith.kt index 41150a3390..58dad3d7b2 100644 --- a/libraries/eventformatter/impl/src/main/kotlin/io/element/android/libraries/eventformatter/impl/PrefixWith.kt +++ b/libraries/eventformatter/impl/src/main/kotlin/io/element/android/libraries/eventformatter/impl/PrefixWith.kt @@ -14,6 +14,9 @@ import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.withStyle +private const val FIRST_STRONG_ISOLATE = 0x2068 +private const val POP_DIRECTIONAL_ISOLATE = 0x2069 + /** * Wraps the string between Unicode isolate characters (FSI … PDI) so its own direction cannot * reorder the text around it. @@ -22,7 +25,7 @@ import androidx.compose.ui.text.withStyle * flips the whole line — the message body ends up on the wrong side of the name and the trailing * colon jumps to the front. See https://github.com/element-hq/element-x-android/issues/3338 */ -internal fun String.bidiIsolate(): String = "⁨$this⁩" +internal fun String.bidiIsolate(): String = Char(FIRST_STRONG_ISOLATE) + this + Char(POP_DIRECTIONAL_ISOLATE) internal fun CharSequence.prefixWith(prefix: String): AnnotatedString { return buildAnnotatedString {