From ad500fed1522b7a8d9c81029c35fabbc37ddbc0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Fri, 30 Aug 2024 14:05:32 +0200 Subject: [PATCH] Move out bidi characters to constant --- src/rules.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/rules.rs b/src/rules.rs index 5ba2318..554e95f 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -1,3 +1,9 @@ +/// List of bidirectional formatting characters from https://en.wikipedia.org/wiki/Trojan_Source +const BIDI_CHARACTERS: &[char] = &[ + '\u{202A}', '\u{202b}', '\u{202c}', '\u{202d}', '\u{202e}', '\u{2066}', '\u{2067}', '\u{2068}', + '\u{2069}', +]; + pub enum Decision { Allow, Deny, @@ -59,12 +65,7 @@ impl CharacterType { match self { Self::CodePoint(rule_char) => *rule_char == c, Self::Range(range) => range.contains(&c), - Self::Bidi => [ - // List of bidirectional formatting characters from https://en.wikipedia.org/wiki/Trojan_Source - '\u{202A}', '\u{202b}', '\u{202c}', '\u{202d}', '\u{202e}', '\u{2066}', '\u{2067}', - '\u{2068}', '\u{2069}', - ] - .contains(&c), + Self::Bidi => BIDI_CHARACTERS.contains(&c), Self::Block(range) => range.contains(&c), Self::Anything => true, }