Compare commits
No commits in common. "a49390e437463d5f9ec1a943c8a60e9ca7de4466" and "f55f37067505a099e261581277bad02548dc1fe8" have entirely different histories.
a49390e437
...
f55f370675
|
|
@ -0,0 +1 @@
|
||||||
|
C:37:"PHPUnit\Runner\DefaultTestResultCache":1921:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:22:{s:67:"LaravelProfaneTests\DictionaryTest::test_words_from_only_one_locale";d:0.006;s:65:"LaravelProfaneTests\DictionaryTest::test_words_from_only_one_file";d:0;s:64:"LaravelProfaneTests\DictionaryTest::test_words_from_locale_array";d:0;s:62:"LaravelProfaneTests\DictionaryTest::test_words_from_file_array";d:0;s:79:"LaravelProfaneTests\ProfaneValidatorTest::test_can_validate_a_word_with_numbers";d:0.001;s:66:"LaravelProfaneTests\ProfaneValidatorTest::test_can_validate_a_text";d:0.001;s:79:"LaravelProfaneTests\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_word";d:0;s:83:"LaravelProfaneTests\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_sentence";d:0;s:86:"LaravelProfaneTests\ProfaneValidatorTest::test_can_evaluate_profanity_of_a_html_string";d:0;s:76:"LaravelProfaneTests\ProfaneValidatorTest::test_can_evaluate_as_caseless_mode";d:0;s:63:"LaravelProfaneTests\ProfaneValidatorTest::test_match_exact_word";d:0;s:82:"LaravelProfaneTests\ProfaneValidatorTest::test_can_validate_a_bad_word_with_accent";d:0;s:75:"LaravelProfaneTests\ProfaneValidatorTest::test_enie_in_spanish_is_evaluated";d:0;s:75:"LaravelProfaneTests\ProfaneValidatorTest::test_can_validate_a_word_in_greek";d:0.001;s:75:"LaravelProfaneTests\ProfaneValidatorTest::test_can_validate_a_text_in_greek";d:0;s:85:"LaravelProfaneTests\StrTest::test_string_contains_a_piece_insensitive_match_from_text";d:0;s:76:"LaravelProfaneTests\StrTest::test_text_contains_insensitive_match_from_array";d:0;s:77:"LaravelProfaneTests\StrTest::test_text_contains_insensitive_match_from_string";d:0;s:86:"LaravelProfaneTests\StrTest::test_text_contains_the_same_insensitive_match_from_string";d:0;s:64:"LaravelProfaneTests\StrTest::test_remove_accents_in_spanish_text";d:0;s:54:"LaravelProfaneTests\StrTest::test_enie_char_is_allowed";d:0;s:57:"LaravelProfaneTests\StrTest::test_remove_accents_in_greek";d:0;}}}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 8.0
|
|
||||||
- 7.4
|
- 7.4
|
||||||
- 7.3
|
- 7.3
|
||||||
- 7.2
|
- 7.2
|
||||||
|
|
|
||||||
2
LICENSE
2
LICENSE
|
|
@ -1,6 +1,6 @@
|
||||||
The MIT License
|
The MIT License
|
||||||
|
|
||||||
Copyright (c) 2016-2021 Arandi López <arandilopez.93@gmail.com>
|
Copyright (c) 2016-2017 Arandi López <arandilopez.93@gmail.com>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
32
README.md
32
README.md
|
|
@ -13,13 +13,11 @@ I made this package to perform a validation for swearwords using Laravel validat
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Install via composer
|
Install via composer
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
composer require arandilopez/laravel-profane
|
composer require arandilopez/laravel-profane
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Add the `ProfaneServiceProvider` class in your `config/app.php` file.
|
Add the `ProfaneServiceProvider` class in your `config/app.php` file.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
|
@ -100,34 +98,10 @@ class MyController extends Controller
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Strict validation
|
|
||||||
|
|
||||||
Now you can strictly validate the exact profane word in the content.
|
|
||||||
|
|
||||||
```php
|
|
||||||
<?php
|
|
||||||
// ...
|
|
||||||
class MyController extends Controller
|
|
||||||
{
|
|
||||||
public function store(Request $request)
|
|
||||||
{
|
|
||||||
$this->validate($request, [
|
|
||||||
'username' => 'required|strictly_profane:es,en'
|
|
||||||
]);
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This fixes known issues when you get a error in validation for words like `class` or `analysis`, as they include `ass` and `anal` respectively, but fails the validation for content like `sucker69`.
|
|
||||||
|
|
||||||
## Getting Help
|
## Getting Help
|
||||||
|
|
||||||
If you're stuck getting something to work, or need to report a bug, please [post an issue in the Github Issues for this project](https://github.com/arandilopez/laravel-profane/issues).
|
If you're stuck getting something to work, or need to report a bug, please [post an issue in the Github Issues for this project](https://github.com/arandilopez/laravel-profane/issues).
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
If you're interesting in contributing code to this project, clone it by running:
|
If you're interesting in contributing code to this project, clone it by running:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|
@ -138,14 +112,13 @@ Please read the [CONTRIBUTING](CONTRIBUTING.md) file.
|
||||||
|
|
||||||
Pull requests are welcome, but please make sure you provide unit tests to cover your changes. **You can help to add and support more locales!**
|
Pull requests are welcome, but please make sure you provide unit tests to cover your changes. **You can help to add and support more locales!**
|
||||||
|
|
||||||
_Thanks to [@dorianneto](https://github.com/dorianneto) for his contributions._
|
*Thanks to [@dorianneto](https://github.com/dorianneto) for his contributions.*
|
||||||
|
|
||||||
### Supported Locales
|
### Supported Locales
|
||||||
|
|
||||||
- English ( provided by [@arandilopez](https://github.com/arandilopez) )
|
- English ( provided by [@arandilopez](https://github.com/arandilopez) )
|
||||||
- Spanish ( provided by [@arandilopez](https://github.com/arandilopez) and [@xDidier901](https://github.com/xDidier901))
|
- Spanish ( provided by [@arandilopez](https://github.com/arandilopez) and [@xDidier901](https://github.com/xDidier901))
|
||||||
- Italian ( provided by [@aletundo](https://github.com/aletundo) )
|
- Italian ( provided by [@aletundo](https://github.com/aletundo) )
|
||||||
- Brazilian Portuguese ( provided by [@ianrodriguesbr](https://github.com/ianrodriguesbr) and [@LeonardoTeixeira](https://github.com/LeonardoTeixeira))
|
- Brazilian Portuguese ( provided by [@ianrodriguesbr](https://github.com/ianrodriguesbr) )
|
||||||
- Traditional Chinese ( provided by [@Nationalcat](https://github.com/Nationalcat) )
|
- Traditional Chinese ( provided by [@Nationalcat](https://github.com/Nationalcat) )
|
||||||
- Slovak ( provided by [@kotass](https://github.com/kotass) )
|
- Slovak ( provided by [@kotass](https://github.com/kotass) )
|
||||||
- Dutch (Netherlands) ( provided by [@Cannonb4ll](https://github.com/Cannonb4ll) and [@WouterVanmulken](https://github.com/WouterVanmulken))
|
- Dutch (Netherlands) ( provided by [@Cannonb4ll](https://github.com/Cannonb4ll) and [@WouterVanmulken](https://github.com/WouterVanmulken))
|
||||||
|
|
@ -158,5 +131,4 @@ _Thanks to [@dorianneto](https://github.com/dorianneto) for his contributions._
|
||||||
- Indonesian ( provided by [@rizasaputra](https://github.com/rizasaputra) )
|
- Indonesian ( provided by [@rizasaputra](https://github.com/rizasaputra) )
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
This project is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
This project is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,15 @@ class ProfaneServiceProvider extends ServiceProvider
|
||||||
__DIR__.'/lang' => resource_path('lang/vendor/laravel-profane'),
|
__DIR__.'/lang' => resource_path('lang/vendor/laravel-profane'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Rule for caseless content matching
|
|
||||||
Validator::extend('profane', 'LaravelProfane\ProfaneValidator@validate', Lang::get('laravel-profane::validation.profane'));
|
Validator::extend('profane', 'LaravelProfane\ProfaneValidator@validate', Lang::get('laravel-profane::validation.profane'));
|
||||||
|
|
||||||
Validator::replacer('profane', function ($message, $attribute) {
|
Validator::replacer('profane', function ($message, $attribute, $rule, $parameters) {
|
||||||
return str_replace(':attribute', $attribute, $message);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Rule for caseless but strict word matching
|
|
||||||
Validator::extend('strictly_profane', 'LaravelProfane\ProfaneValidator@validateStrict', Lang::get('laravel-profane::validation.profane'));
|
|
||||||
|
|
||||||
Validator::replacer('strictly_profane', function ($message, $attribute) {
|
|
||||||
return str_replace(':attribute', $attribute, $message);
|
return str_replace(':attribute', $attribute, $message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
// code...
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,27 @@
|
||||||
|
|
||||||
namespace LaravelProfane;
|
namespace LaravelProfane;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\Validator;
|
||||||
|
|
||||||
class ProfaneValidator
|
class ProfaneValidator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Dictionary
|
* [$dictionary description].
|
||||||
|
*
|
||||||
|
* @var [type]
|
||||||
*/
|
*/
|
||||||
protected $dictionary;
|
protected $dictionary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* [$badwords description].
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $badwords = [];
|
protected $badwords = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* [__construct description].
|
||||||
|
*
|
||||||
* @param Dictionary $dictionary [description]
|
* @param Dictionary $dictionary [description]
|
||||||
*/
|
*/
|
||||||
public function __construct(Dictionary $dictionary)
|
public function __construct(Dictionary $dictionary)
|
||||||
|
|
@ -24,41 +32,25 @@ class ProfaneValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to extends to Validation Service.
|
* Method to extends to Validator.
|
||||||
*
|
*
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @param mixed $value
|
* @param midex $value
|
||||||
* @param array $parameters
|
* @param array $parameters
|
||||||
|
* @param \Illuminate\Contracts\Validation\Validator $validator [description]
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function validate($attribute, $value, $parameters)
|
public function validate($attribute, $value, $parameters)
|
||||||
{
|
{
|
||||||
if ($parameters) {
|
if ($parameters) {
|
||||||
$this->setDictionary($parameters);
|
$this->dictionary->setDictionary($parameters);
|
||||||
|
$this->badwords = $this->dictionary->getDictionary();
|
||||||
}
|
}
|
||||||
|
|
||||||
return !$this->isProfane($value);
|
return !$this->isProfane($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to extends to Validation Service for strict word matching.
|
|
||||||
*
|
|
||||||
* @param string $attribute
|
|
||||||
* @param mixed $value
|
|
||||||
* @param array $parameters
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function validateStrict($attribute, $value, $parameters)
|
|
||||||
{
|
|
||||||
if ($parameters) {
|
|
||||||
$this->setDictionary($parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
return !$this->isProfane($value, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check profanity of text.
|
* Check profanity of text.
|
||||||
*
|
*
|
||||||
|
|
@ -66,23 +58,11 @@ class ProfaneValidator
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isProfane($text, $strict = false)
|
public function isProfane($text)
|
||||||
{
|
{
|
||||||
return Str::containsCaseless(
|
return Str::containsCaseless(
|
||||||
$this->sanitizeText($text),
|
Str::removeAccent($text),
|
||||||
$this->badwords,
|
$this->badwords
|
||||||
$strict
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setDictionary($dictionaries)
|
|
||||||
{
|
|
||||||
$this->dictionary->setDictionary($dictionaries);
|
|
||||||
$this->badwords = $this->dictionary->getDictionary();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function sanitizeText($text)
|
|
||||||
{
|
|
||||||
return Str::removeAccent(strip_tags($text));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,11 @@ class Str
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function containsCaseless($haystack, $needles, $strict = false)
|
public static function containsCaseless($haystack, $needles)
|
||||||
{
|
{
|
||||||
foreach ((array) $needles as $needle) {
|
foreach ((array) $needles as $needle) {
|
||||||
$needle = preg_quote($needle);
|
$needle = preg_quote($needle);
|
||||||
$regex = $strict ? "/\b$needle\b/iu" : "/$needle/iu";
|
if ($needle != '' && preg_match("/$needle/iu", $haystack)) {
|
||||||
if ($needle != '' && preg_match($regex, $haystack)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,323 +3,66 @@
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Filter the following list when this language is used.
|
| Filter the following list when this language is used.
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Provided by @ianrodriguesbr and @LeonardoTeixeira
|
| Provided by @ianrodriguesbr
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
'abestada',
|
'aborto',
|
||||||
'abestado',
|
'anal',
|
||||||
'acefalo',
|
|
||||||
'alienada',
|
|
||||||
'alienado',
|
|
||||||
'animal de teta',
|
|
||||||
'anta',
|
|
||||||
'anus',
|
'anus',
|
||||||
'arregacada',
|
|
||||||
'arregacado',
|
|
||||||
'arrombada',
|
|
||||||
'arrombado',
|
|
||||||
'babaca',
|
|
||||||
'bacura',
|
|
||||||
'bagos',
|
|
||||||
'baitola',
|
|
||||||
'baleia',
|
|
||||||
'bebum',
|
|
||||||
'besta',
|
|
||||||
'biba',
|
|
||||||
'bicha',
|
'bicha',
|
||||||
'bisca',
|
|
||||||
'bixa',
|
|
||||||
'boazuda',
|
|
||||||
'bobo',
|
|
||||||
'boceta',
|
'boceta',
|
||||||
'bocetao',
|
|
||||||
'bocetuda',
|
|
||||||
'boco',
|
|
||||||
'boiola',
|
|
||||||
'bolagato',
|
|
||||||
'bolcat',
|
|
||||||
'boquete',
|
'boquete',
|
||||||
'boqueteiro',
|
|
||||||
'bosseta',
|
|
||||||
'bosta',
|
'bosta',
|
||||||
'bostana',
|
|
||||||
'bocal',
|
|
||||||
'braulio',
|
|
||||||
'brioco',
|
|
||||||
'bronha',
|
|
||||||
'buca',
|
|
||||||
'buceta',
|
'buceta',
|
||||||
'bucetao',
|
|
||||||
'bucetuda',
|
|
||||||
'bunda',
|
'bunda',
|
||||||
'bunduda',
|
'bundao',
|
||||||
'burra',
|
|
||||||
'burro',
|
|
||||||
'busseta',
|
|
||||||
'cacete',
|
'cacete',
|
||||||
'cachorra',
|
|
||||||
'cachorro',
|
|
||||||
'cadela',
|
|
||||||
'cadelona',
|
|
||||||
'caga',
|
|
||||||
'cagado',
|
|
||||||
'cagao',
|
'cagao',
|
||||||
'cagona',
|
|
||||||
'canalha',
|
|
||||||
'caralho',
|
'caralho',
|
||||||
'casseta',
|
'chupeta',
|
||||||
'cassete',
|
|
||||||
'charlatao',
|
|
||||||
'checheca',
|
|
||||||
'chereca',
|
|
||||||
'chibumba',
|
|
||||||
'chibumbo',
|
|
||||||
'chifruda',
|
|
||||||
'chifrudo',
|
|
||||||
'chochota',
|
|
||||||
'chota',
|
|
||||||
'chupada',
|
|
||||||
'chupado',
|
|
||||||
'clitoris',
|
|
||||||
'corna',
|
|
||||||
'corno',
|
|
||||||
'cornuda',
|
|
||||||
'cornudo',
|
|
||||||
'corrupta',
|
|
||||||
'corrupto',
|
|
||||||
'cretina',
|
|
||||||
'cretino',
|
|
||||||
'cu',
|
|
||||||
'culhao',
|
|
||||||
'curalho',
|
|
||||||
'cuzao',
|
'cuzao',
|
||||||
'cuzuda',
|
'cu',
|
||||||
'cuzudo',
|
'estupro',
|
||||||
'debil',
|
|
||||||
'debil mental',
|
|
||||||
'debiloide',
|
|
||||||
'demente',
|
|
||||||
'demonio',
|
|
||||||
'desgraca',
|
'desgraca',
|
||||||
'desgracado',
|
|
||||||
'drogado',
|
|
||||||
'egua',
|
|
||||||
'embessil',
|
|
||||||
'endemoniado',
|
|
||||||
'energumeno',
|
|
||||||
'escrota',
|
|
||||||
'escroto',
|
|
||||||
'esporrada',
|
|
||||||
'esporrado',
|
|
||||||
'esporro',
|
|
||||||
'estrume',
|
|
||||||
'estupida',
|
|
||||||
'estupidez',
|
|
||||||
'estupido',
|
|
||||||
'fdp',
|
|
||||||
'fedida',
|
|
||||||
'fedido',
|
|
||||||
'fedor',
|
|
||||||
'fedorenta',
|
|
||||||
'feia',
|
|
||||||
'feio',
|
|
||||||
'feiosa',
|
|
||||||
'feioso',
|
|
||||||
'feioza',
|
|
||||||
'feiozo',
|
|
||||||
'filho da puta',
|
|
||||||
'fiofo',
|
|
||||||
'foda',
|
'foda',
|
||||||
'foda se',
|
'foder',
|
||||||
'foda-se',
|
'gozar',
|
||||||
'fodao',
|
|
||||||
'fodase',
|
|
||||||
'fode',
|
|
||||||
'fodida',
|
|
||||||
'fodido',
|
|
||||||
'fornica',
|
|
||||||
'fudecao',
|
|
||||||
'fudendo',
|
|
||||||
'fudida',
|
|
||||||
'fudido',
|
|
||||||
'furada',
|
|
||||||
'furado',
|
|
||||||
'furnica',
|
|
||||||
'furnicar',
|
|
||||||
'furona',
|
|
||||||
'furao',
|
|
||||||
'gaiata',
|
|
||||||
'gaiato',
|
|
||||||
'gay',
|
|
||||||
'grelinho',
|
|
||||||
'grelo',
|
|
||||||
'idiota',
|
'idiota',
|
||||||
'imbecil',
|
'imbecil',
|
||||||
'imundo',
|
'inferno',
|
||||||
'iscrota',
|
'masturbacao',
|
||||||
'iscroto',
|
|
||||||
'jacu',
|
|
||||||
'jamanta',
|
|
||||||
'jegue',
|
|
||||||
'jumento',
|
|
||||||
'k-tchorra',
|
|
||||||
'karalho',
|
|
||||||
'kct',
|
|
||||||
'kenga',
|
|
||||||
'ku',
|
|
||||||
'ladra',
|
|
||||||
'ladrao',
|
|
||||||
'ladroeira',
|
|
||||||
'ladrona',
|
|
||||||
'lalau',
|
|
||||||
'lazarento',
|
|
||||||
'leprosa',
|
|
||||||
'leproso',
|
|
||||||
'lezado',
|
|
||||||
'lesbica',
|
|
||||||
'macaca',
|
|
||||||
'macaco',
|
|
||||||
'machona',
|
|
||||||
'machorra',
|
|
||||||
'maconheiro',
|
|
||||||
'maldita',
|
|
||||||
'maldito',
|
|
||||||
'manguaca',
|
|
||||||
'manguaça',
|
|
||||||
'masturba',
|
|
||||||
'meleca',
|
|
||||||
'merda',
|
'merda',
|
||||||
'meretriz',
|
'mijar',
|
||||||
'mija',
|
'orgasmo',
|
||||||
'mijada',
|
'orgia',
|
||||||
'mijado',
|
|
||||||
'mijo',
|
|
||||||
'mocrea',
|
|
||||||
'mocreia',
|
|
||||||
'moleca',
|
|
||||||
'moleque',
|
|
||||||
'mondronga',
|
|
||||||
'mondrongo',
|
|
||||||
'naba',
|
|
||||||
'nadega',
|
|
||||||
'nariguda',
|
|
||||||
'narigudo',
|
|
||||||
'nhaca',
|
|
||||||
'nojeira',
|
|
||||||
'nojenta',
|
|
||||||
'nojento',
|
|
||||||
'nojo',
|
|
||||||
'ogra',
|
|
||||||
'ogro',
|
|
||||||
'olhota',
|
|
||||||
'otaria',
|
|
||||||
'otario',
|
'otario',
|
||||||
'paca',
|
|
||||||
'panaca',
|
'panaca',
|
||||||
'paspalha',
|
|
||||||
'paspalhao',
|
|
||||||
'paspalho',
|
|
||||||
'pau',
|
'pau',
|
||||||
'pau no cu',
|
|
||||||
'peido',
|
|
||||||
'pemba',
|
|
||||||
'penis',
|
|
||||||
'pentelha',
|
|
||||||
'pentelho',
|
|
||||||
'perequita',
|
|
||||||
'perereca',
|
|
||||||
'pica',
|
|
||||||
'picao',
|
|
||||||
'pilantra',
|
|
||||||
'pinto pequeno',
|
|
||||||
'piranha',
|
|
||||||
'piroca',
|
'piroca',
|
||||||
'piroco',
|
'porno',
|
||||||
'piru',
|
|
||||||
'porra',
|
'porra',
|
||||||
'pqp',
|
|
||||||
'prega',
|
|
||||||
'prostibulo',
|
|
||||||
'prostituta',
|
'prostituta',
|
||||||
'prostituto',
|
|
||||||
'punheta',
|
'punheta',
|
||||||
'punhetao',
|
|
||||||
'punheteiro',
|
'punheteiro',
|
||||||
'pustula',
|
|
||||||
'puta',
|
'puta',
|
||||||
'puta que pariu',
|
'putaria',
|
||||||
'puto',
|
|
||||||
'puxa saco',
|
|
||||||
'puxa-saco',
|
|
||||||
'puxasaco',
|
|
||||||
'penis',
|
'penis',
|
||||||
'quenga',
|
|
||||||
'rabao',
|
|
||||||
'rabo',
|
|
||||||
'rabuda',
|
|
||||||
'rabudao',
|
|
||||||
'rabudo',
|
|
||||||
'rabudona',
|
|
||||||
'racha',
|
|
||||||
'rachada',
|
|
||||||
'rachadao',
|
|
||||||
'rachadinha',
|
|
||||||
'rachadinho',
|
|
||||||
'rachado',
|
|
||||||
'rapariga',
|
'rapariga',
|
||||||
'rato de esgoto',
|
|
||||||
'retardada',
|
|
||||||
'retardado',
|
|
||||||
'ridicula',
|
|
||||||
'ridiculo',
|
|
||||||
'rola',
|
'rola',
|
||||||
'rolinha',
|
|
||||||
'rosca',
|
|
||||||
'sacana',
|
|
||||||
'safada',
|
|
||||||
'safado',
|
|
||||||
'sapatao',
|
'sapatao',
|
||||||
'sifilis',
|
'semen',
|
||||||
|
'sex',
|
||||||
|
'sexo',
|
||||||
|
'sexy',
|
||||||
'siririca',
|
'siririca',
|
||||||
'tarada',
|
'semen',
|
||||||
'tarado',
|
'testiculo',
|
||||||
'tesao',
|
'teta',
|
||||||
'testuda',
|
'traseiro',
|
||||||
'tetuda',
|
|
||||||
'tetudo',
|
|
||||||
'tezao',
|
|
||||||
'tezuda',
|
|
||||||
'tezudo',
|
|
||||||
'tnc',
|
|
||||||
'travecao',
|
|
||||||
'traveco',
|
|
||||||
'trocha',
|
|
||||||
'trolha',
|
|
||||||
'troucha',
|
|
||||||
'trouxa',
|
|
||||||
'troxa',
|
|
||||||
'vaca',
|
|
||||||
'vadia',
|
|
||||||
'vagabunda',
|
|
||||||
'vagabundo',
|
|
||||||
'vagina',
|
'vagina',
|
||||||
'veada',
|
|
||||||
'veadao',
|
|
||||||
'veado',
|
|
||||||
'verme',
|
|
||||||
'viada',
|
|
||||||
'viadao',
|
|
||||||
'viado',
|
'viado',
|
||||||
'vsf',
|
'vibrador',
|
||||||
'xana',
|
'vulva',
|
||||||
'xaninha',
|
|
||||||
'xavasca',
|
|
||||||
'xerereca',
|
|
||||||
'xexeca',
|
|
||||||
'xibiu',
|
|
||||||
'xibumba',
|
|
||||||
'xochota',
|
|
||||||
'xota',
|
|
||||||
'xoxota',
|
'xoxota',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,6 @@ class ProfaneValidatorTest extends TestCase
|
||||||
$this->assertFalse($builder->validate(['username', 'culero23', ['es']]));
|
$this->assertFalse($builder->validate(['username', 'culero23', ['es']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_can_not_validate_a_word_with_numbers_in_strict_mode()
|
|
||||||
{
|
|
||||||
$builder = new ProfaneValidatorBuilder();
|
|
||||||
|
|
||||||
$this->assertTrue($builder->validate(['username', 'culero23', ['es']], true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_can_validate_a_text()
|
public function test_can_validate_a_text()
|
||||||
{
|
{
|
||||||
$builder = new ProfaneValidatorBuilder();
|
$builder = new ProfaneValidatorBuilder();
|
||||||
|
|
@ -45,15 +38,6 @@ class ProfaneValidatorTest extends TestCase
|
||||||
$this->assertTrue($builder->build()->isProfane($word));
|
$this->assertTrue($builder->build()->isProfane($word));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_can_evaluate_profanity_of_a_sentence_in_strict_mode()
|
|
||||||
{
|
|
||||||
$builder = new ProfaneValidatorBuilder();
|
|
||||||
|
|
||||||
$word = 'fuck you if you read this';
|
|
||||||
|
|
||||||
$this->assertTrue($builder->build()->isProfane($word), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_can_evaluate_profanity_of_a_html_string()
|
public function test_can_evaluate_profanity_of_a_html_string()
|
||||||
{
|
{
|
||||||
$builder = new ProfaneValidatorBuilder();
|
$builder = new ProfaneValidatorBuilder();
|
||||||
|
|
@ -72,7 +56,7 @@ class ProfaneValidatorTest extends TestCase
|
||||||
$this->assertTrue($builder->build()->isProfane($word));
|
$this->assertTrue($builder->build()->isProfane($word));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_match_content()
|
public function test_match_exact_word()
|
||||||
{
|
{
|
||||||
$builder = new ProfaneValidatorBuilder();
|
$builder = new ProfaneValidatorBuilder();
|
||||||
|
|
||||||
|
|
@ -83,17 +67,6 @@ class ProfaneValidatorTest extends TestCase
|
||||||
$this->assertTrue($builder->build()->isProfane('sucker96'));
|
$this->assertTrue($builder->build()->isProfane('sucker96'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_match_exact_word_in_strict_mode()
|
|
||||||
{
|
|
||||||
$builder = new ProfaneValidatorBuilder();
|
|
||||||
|
|
||||||
// class is a safe word
|
|
||||||
$this->assertFalse($builder->build()->isProfane('class', true));
|
|
||||||
|
|
||||||
// in strict mode this will pass a safe word
|
|
||||||
$this->assertFalse($builder->build()->isProfane('sucker96', true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_can_validate_a_bad_word_with_accent()
|
public function test_can_validate_a_bad_word_with_accent()
|
||||||
{
|
{
|
||||||
$builder = new ProfaneValidatorBuilder('sk');
|
$builder = new ProfaneValidatorBuilder('sk');
|
||||||
|
|
|
||||||
|
|
@ -21,25 +21,6 @@ class StrTest extends TestCase
|
||||||
$this->assertTrue(Str::containsCaseless('Fuck! This class is so bad!', 'fUcK'));
|
$this->assertTrue(Str::containsCaseless('Fuck! This class is so bad!', 'fUcK'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_text_does_not_contain_match_in_strict_mode()
|
|
||||||
{
|
|
||||||
$this->assertFalse(Str::containsCaseless('This class is so bad!', 'ass', true));
|
|
||||||
$this->assertFalse(Str::containsCaseless('Theorem Analisys', 'anal', true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_text_contains_match_in_strict_mode()
|
|
||||||
{
|
|
||||||
$this->assertTrue(Str::containsCaseless('This class is a crap!', 'crap', true));
|
|
||||||
$this->assertFalse(Str::containsCaseless('Theorem Analisys', 'anal', true));
|
|
||||||
$this->assertFalse(Str::containsCaseless('Sucker69', 'sucker', true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_text_contains_match_in_not_strict_mode()
|
|
||||||
{
|
|
||||||
$this->assertTrue(Str::containsCaseless('This class is so bad!', 'ass', false));
|
|
||||||
$this->assertTrue(Str::containsCaseless('Theorem Analisys', 'anal', false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_text_contains_the_same_insensitive_match_from_string()
|
public function test_text_contains_the_same_insensitive_match_from_string()
|
||||||
{
|
{
|
||||||
$this->assertTrue(Str::containsCaseless('Fuck! This class is so bad!', 'Fuck'));
|
$this->assertTrue(Str::containsCaseless('Fuck! This class is so bad!', 'Fuck'));
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,10 @@ class ProfaneValidatorBuilder
|
||||||
*
|
*
|
||||||
* @return [type] [description]
|
* @return [type] [description]
|
||||||
*/
|
*/
|
||||||
public function validate(array $parameters, $strict = false)
|
public function validate(array $parameters)
|
||||||
{
|
{
|
||||||
list($attribute, $text, $dictionaries) = $parameters;
|
list($attribute, $text, $dictionaries) = $parameters;
|
||||||
|
|
||||||
if ($strict) {
|
|
||||||
return $this->build()->validateStrict($attribute, $text, $dictionaries);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->build()->validate($attribute, $text, $dictionaries);
|
return $this->build()->validate($attribute, $text, $dictionaries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue