webchemistry/html-purifier
Composer 安装命令:
composer require webchemistry/html-purifier
包简介
Html purifier
README 文档
README
Usage:
$rules = new Rules(); $rules->addMulti( ElementRule::create('i'), ElementRule::create('div'), ElementRule::create('strong') ->addAttributeRule( AttributeRule::create('class') ->allowValue('italic') ), ElementRule::create('script') ->discard(), ElementRule::create('span') ->addAttributeRule( AttributeStyleRule::create() ->addRule('color', ['white', '#fff', '#fffff']) ) ); $purifier = new Purifier($rules); $purifier->purify(' <div> Lorem ipsum <strong class="italic h2">is simply</strong> <script>alert("dummy text!")</script> <span style="color: #FFF;font-weight: bold">white</span> and <span style="color: red">red</span> <br> </div> ');
output:
<div> Lorem ipsum <strong class="italic">is simply</strong> <span style="color: #FFF;">white</span> and <span>red</span> </div>
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-03-13