<commit_before># HTMLPurifier
 **描述**

 简单封装HTMLPurifier的富文本过滤器，自定义白名单机制，有效杜绝了用户提交表单中的非法HTML标签，从而可以防止XSS攻击！

 Laravel框架下的请参考：https://github.com/LukeTowers/Purifier

 **安装**

```php
   sudo composer require "yvan/purifier"
```

 **使用**

```php
$params = [
'one' => '<h1>one</h1>',
'two' => '<h1><script>alert(123);</script>two</h1>',
];
$purifier = new Purifier();
$result = $purifier->remove($params);
print_r($result);

`打印结果：`

Array
(
[one] => <p>one</p>
[two] => <p>two</p>
)
```

**白名单配置**

   `路径：config\purifier.php`

```php
    return [
        'encoding' => 'utf-8', //编码
        'finalize' => true, //固定<commit_msg>namespace<commit_after># HTMLPurifier
 **描述**

 简单封装HTMLPurifier的富文本过滤器，自定义白名单机制，有效杜绝了用户提交表单中的非法HTML标签，从而可以防止XSS攻击！

 Laravel框架下的请参考：https://github.com/LukeTowers/Purifier

 **安装**

```php
   sudo composer require "yvan/purifier"
```

 **使用**

```php
  $params = [
    'one' => '<h1>one</h1>',
    'two' => '<h1><script>alert(123);</script>two</h1>',
    ];
  $purifier = new \Yvan\Purifier\Purifier();
  $result = $purifier->remove($params);
  print_r($result);
```

**打印结果：**
```php
  Array
  (
    [one] => <p>one</p>
    [two] => <p>two</p>
  )
```

**白名单配置**

   `路径：config\purifier.php`

```php
    return [
        'encoding' => 'utf-8', //编码
        'finalize' => true, //固定
{'fraction_non_alphanumeric': 0.23794950267788828, 'fraction_numerical': 0.01224177505738332, 'mean_word_length': 3.8265682656826567, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 37, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6657990', 'n_tokens_mistral': 664, 'n_tokens_neox': 679, 'n_words': 80}