From 01cf597b5d305c74e9e63c82f7bb68c3b2de8a63 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 22 Oct 2024 17:51:58 -0400 Subject: [PATCH] Account for bidi text in combined display/username label --- Tusker/Views/AccountDisplayAndUserNameLabel.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tusker/Views/AccountDisplayAndUserNameLabel.swift b/Tusker/Views/AccountDisplayAndUserNameLabel.swift index 0e963503..be09d32d 100644 --- a/Tusker/Views/AccountDisplayAndUserNameLabel.swift +++ b/Tusker/Views/AccountDisplayAndUserNameLabel.swift @@ -30,7 +30,9 @@ class AccountDisplayAndUserNameLabel: EmojiLabel { private func makeAttributedText(state: State) -> NSAttributedString { let s = NSMutableAttributedString() - s.append(NSAttributedString(string: state.displayName, attributes: [ + // U+2068 FIRST-STRONG ISOLATE and U+2069 POP DIRECTIONAL ISOLATE + // to prevent bidi text in the display name influencing the username + s.append(NSAttributedString(string: "\u{2068}\(state.displayName)\u{2069}", attributes: [ .font: UIFont(descriptor: baseFont.addingAttributes([ .traits: [ UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold.rawValue,