elementareteilchen/html-purify

添加html purify功能作为视图助手和服务类

安装: 143

依赖: 0

建议: 0

安全性: 0

星星: 3

关注者: 4

分支: 1

公开问题: 0

类型:typo3-cms-extension

v2.0.0 2024-07-04 09:52 UTC

This package is auto-updated.

Last update: 2024-09-04 10:21:41 UTC


README

净化HTML,以防止XSS攻击或不需要的HTML。

特性

此扩展为您提供了净化特定HTML的机会,这些HTML可能不完全受您控制,以消除可能的跨站脚本(XSS)攻击。

安装

只需使用Composer安装扩展。

composer require elementareteilchen/html-purify

此扩展使用ezyang/htmlpurifier,它被设置为Composer要求以自动加载。

使用方法

视图助手

<hp:purify allowedHtmlTags="strong,em">{someVariableWithPotentialXSS -> f:format.raw()}</hp:purify>
{someVariableWithPotentialXSS -> f:format.raw() -> hp:purify()}
{hp:purify(allowedHtmlTags: 'p,strong', htmlContent: '<p>Text with <strong>HTML</strong> but <em>EM will be removed</em></p>')}

PHP代码中的服务

$purifiedHtml = \ElementareTeilchen\HtmlPurify\Service\PurifyService::purify($htmlContent, $allowedHtmlTags);