@@ -4,10 +4,10 @@ namespace Cliptok.Checks
4
4
{
5
5
public class ListChecks
6
6
{
7
- // Map of Cyrillic to Latin characters, to catch attempted bypasses using Cyrillic lookalikes
8
- // <string, string> is <Cyrillic, Latin>
9
- public static Dictionary < string , string > alphabetMap = new ( )
7
+ // Map of lookalike to Latin characters, to catch attempted bypasses using different language lookalikes
8
+ public static Dictionary < string , string > lookalikeAlphabetMap = new ( )
10
9
{
10
+ // <string, string> is <Cyrillic, Latin>
11
11
{ "А" , "A" } ,
12
12
{ "В" , "B" } ,
13
13
{ "С" , "C" } ,
@@ -47,15 +47,45 @@ public class ListChecks
47
47
{ "ѡ" , "w" } ,
48
48
{ "х" , "x" } ,
49
49
{ "у" , "y" } ,
50
- { "У" , "y" }
51
- } ;
50
+ { "У" , "y" } ,
52
51
52
+ // <string, string> is <Greek, Latin>
53
+ { "Α" , "A" } ,
54
+ { "Β" , "B" } ,
55
+ { "Ε" , "E" } ,
56
+ { "Η" , "H" } ,
57
+ { "Ι" , "I" } ,
58
+ { "Κ" , "K" } ,
59
+ { "Μ" , "M" } ,
60
+ { "Ν" , "N" } ,
61
+ { "Ο" , "O" } ,
62
+ { "Ρ" , "P" } ,
63
+ { "Τ" , "T" } ,
64
+ { "Χ" , "X" } ,
65
+ { "Υ" , "Y" } ,
66
+ { "Ζ" , "Z" } ,
67
+ { "α" , "a" } ,
68
+ { "β" , "b" } ,
69
+ { "ε" , "e" } ,
70
+ { "η" , "h" } ,
71
+ { "ι" , "i" } ,
72
+ { "κ" , "k" } ,
73
+ { "μ" , "m" } ,
74
+ { "ν" , "n" } ,
75
+ { "ο" , "o" } ,
76
+ { "ρ" , "p" } ,
77
+ { "τ" , "t" } ,
78
+ { "χ" , "x" } ,
79
+ { "υ" , "y" } ,
80
+ { "ζ" , "z" } ,
81
+ } ;
82
+
53
83
public static ( bool success , string ? flaggedWord ) CheckForNaughtyWords ( string input , WordListJson naughtyWordList )
54
84
{
55
- // Replace any Cyrillic letters found in message with Latin characters, if in the dictionary
56
- foreach ( var letter in alphabetMap )
85
+ // Replace any lookalike letters found in message with Latin characters, if in the dictionary
86
+ foreach ( var letter in lookalikeAlphabetMap )
57
87
input = input . Replace ( letter . Key , letter . Value ) ;
58
-
88
+
59
89
string [ ] naughtyWords = naughtyWordList . Words ;
60
90
input = input . Replace ( "\0 " , "" ) ;
61
91
if ( naughtyWordList . WholeWord )
0 commit comments