Skip to content

Commit

Permalink
Move out bidi characters to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Aug 30, 2024
1 parent 53ca585 commit ad500fe
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/rules.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
}
Expand Down

0 comments on commit ad500fe

Please sign in to comment.