mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-10-25 07:41:41 +00:00
fix(composer): accept combining marks in @mention regex
NFD nicknames are base letters plus \p{M}; the old \p{L}-only pattern
stopped before the accent so NFC peer lookup never saw a match.
This commit is contained in:
parent
89b449a8a1
commit
7162d3f451
@ -41,7 +41,9 @@ final class MessageFormattingEngine {
|
||||
enum Patterns {
|
||||
static let hashtag = SafeRegex.compile("#([a-zA-Z0-9_]+)")
|
||||
|
||||
static let mention = SafeRegex.compile("@([\\p{L}0-9_]+(?:#[a-fA-F0-9]{4})?)")
|
||||
// Include \p{M} so NFD nicknames (base letter + combining mark) still
|
||||
// parse as one mention token; NFC forms are covered by \p{L} alone.
|
||||
static let mention = SafeRegex.compile("@([\\p{L}\\p{M}0-9_]+(?:#[a-fA-F0-9]{4})?)")
|
||||
|
||||
static let cashu = SafeRegex.compile("\\bcashu[AB][A-Za-z0-9._-]{40,}\\b")
|
||||
|
||||
|
||||
@ -116,6 +116,9 @@ final class ChatComposerCoordinator {
|
||||
}
|
||||
|
||||
func parseMentions(from content: String) -> [String] {
|
||||
// Canonicalize before matching so NFD typed text and NFC peer tokens
|
||||
// share one codepoint sequence (regex also accepts combining marks).
|
||||
let content = content.precomposedStringWithCanonicalMapping
|
||||
let regex = ChatViewModel.Patterns.mention
|
||||
let nsContent = content as NSString
|
||||
let matches = regex.matches(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user