Skip to content

Commit 34bec8c

Browse files
authored
Merge pull request #14 from wrighter989/master
Fix validation to not break validation of other fields, added boolean method to check for profanity
2 parents 93dbc6b + 1eb2149 commit 34bec8c

3 files changed

Lines changed: 87 additions & 9 deletions

File tree

app/ProfanityFilter.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,25 @@ public function filter($string, $details = null)
9898
return $filtered;
9999
}
100100

101+
public function noProfanity($string)
102+
{
103+
$this->resetFiltered();
104+
105+
if (!is_string($string) || !trim($string)) {
106+
return;
107+
}
108+
109+
$filtered = $this->filterString($string);
110+
111+
foreach ($this->badWords as $badword) {
112+
if (stripos($string, $badword) !== false) {
113+
return false;
114+
}
115+
}
116+
117+
return true;
118+
}
119+
101120
private function filterString($string)
102121
{
103122
return preg_replace_callback($this->filterChecks, function ($matches) {

app/Providers/ProfanityFilterServiceProvider.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,7 @@ public function boot()
3838
], 'config');
3939

4040
app('validator')->extend('profanity', function ($attribute, $value, $parameters, $validator) {
41-
$replace = [
42-
$attribute => app('profanityFilter')->filter($value),
43-
];
44-
45-
request()->replace($replace);
46-
47-
$validator->setData($replace);
48-
49-
return true;
41+
return app('profanityFilter')->noProfanity($value);
5042
});
5143
}
5244
}

resources/lang/en/profanity.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,72 @@
1010
|
1111
*/
1212

13+
'anal',
14+
'anus',
15+
'arse',
16+
'ass',
17+
'ballsack',
18+
'balls',
19+
'bastard',
20+
'bitch',
21+
'biatch',
22+
'bloody',
23+
'blowjob',
24+
'bollock',
25+
'bollok',
26+
'boner',
27+
'boob',
28+
'bugger',
29+
'bum',
30+
'butt',
31+
'buttplug',
32+
'clitoris',
33+
'cock',
34+
'coon',
35+
'crap',
1336
'cunt',
37+
'damn',
38+
'dick',
39+
'dildo',
40+
'dyke',
41+
'fag',
42+
'feck',
43+
'fellate',
44+
'fellatio',
45+
'felching',
46+
'fuck',
47+
'fudgepacker',
48+
'flange',
49+
'goddamn',
50+
'hell',
51+
'homo',
52+
'jizz',
53+
'knobend',
54+
'labia',
55+
'muff',
56+
'nigger',
57+
'nigga',
58+
'penis',
59+
'piss',
60+
'poop',
61+
'prick',
62+
'pube',
63+
'pussy',
64+
'queer',
65+
'scrotum',
66+
'sex',
67+
'shit',
68+
'sh1t',
69+
'slut',
70+
'smegma',
71+
'spunk',
72+
'suck',
73+
'tit',
74+
'tosser',
75+
'turd',
76+
'twat',
77+
'vagina',
78+
'wank',
79+
'whore',
80+
'wtf',
1481
];

0 commit comments

Comments
 (0)