File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -623,16 +623,12 @@ public function __construct(
623
623
);
624
624
}
625
625
626
+ // Filter out blocklist words that are shorter than 3 characters or contain non-alphabet characters
626
627
$ filteredBlocklist = [];
627
- $ alphabetChars = str_split (strtolower ($ alphabet ));
628
- foreach ((array ) $ blocklist as $ word ) {
629
- if (strlen ((string ) $ word ) >= 3 ) {
630
- $ wordLowercased = strtolower ($ word );
631
- $ wordChars = str_split ((string ) $ wordLowercased );
632
- $ intersection = array_filter ($ wordChars , fn ($ c ) => in_array ($ c , $ alphabetChars ));
633
- if (count ($ intersection ) == count ($ wordChars )) {
634
- $ filteredBlocklist [] = strtolower ((string ) $ wordLowercased );
635
- }
628
+ $ alphabetPattern = '/^[ ' . preg_quote ($ alphabet , '/ ' ) . ']+$/i ' ;
629
+ foreach ($ blocklist as $ word ) {
630
+ if (strlen ((string ) $ word ) >= 3 && preg_match ($ alphabetPattern , $ word )) {
631
+ $ filteredBlocklist [] = strtolower ((string ) $ word );
636
632
}
637
633
}
638
634
You can’t perform that action at this time.
0 commit comments