elementareteilchen/html-purify

Adds html purify functionality as viewhelper and service class

Maintainers

Package info

github.com/ElementareTeilchen/html_purify

Type:typo3-cms-extension

pkg:composer/elementareteilchen/html-purify

Statistics

Installs: 281

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 0

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

This package is auto-updated.

Last update: 2026-03-04 13:52:06 UTC


README

Purify HTML to prevent XSS attacks or unwanted HTML.

Features

This extension provides you with opportunities to purify specific HTML which may is not fully under your control in order to remove possible Cross-Site-Scripting (XSS) attacks.

Installation

Simply install the extension with Composer.

composer require elementareteilchen/html-purify

This extension uses ezyang/htmlpurifier, which is set as composer requirement to be loaded automatically.

Usage

Viewhelper

<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>')}

Service in PHP code

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