Skip to content

Commit a1d9891

Browse files
authored
Merge pull request #1 from wmde/text-policy-spaces
Allow spaces in text policy word list
2 parents 75da008 + f2fae27 commit a1d9891

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Validators/TextPolicyValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private function isExistingDomain( string $domainName ): bool {
159159
private function composeRegex( array $wordArray ): string {
160160
$quotedWords = array_map(
161161
function ( string $word ) {
162-
return preg_quote( $word, '#' );
162+
return str_replace( ' ', '\\s*', preg_quote( trim( $word ), '#' ) );
163163
},
164164
$wordArray
165165
);

tests/System/TextPolicyValidatorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ public function insultingTestProvider(): array {
112112
[ 'Heil Hitler!' ],
113113
[ 'Duhamsterfresse!!!' ],
114114
[ 'Alles nur HAMSTERFRESSEN!!!!!!!!1111111111' ],
115+
[ 'SiegHeil' ],
116+
[ 'Sieg Heil' ],
117+
[ "Sieg \n\tHeil!" ]
115118
];
116119
}
117120

@@ -198,7 +201,8 @@ private function getPreFilledTextPolicyValidator(): TextPolicyValidator {
198201
'deppen',
199202
'hitler',
200203
'hamsterfresse',
201-
'arsch'
204+
'arsch',
205+
'sieg heil'
202206
] );
203207
$textPolicyValidator->addWhiteWordsFromArray(
204208
[

0 commit comments

Comments
 (0)