freepik-labs/dom-purify

A JS DOMPurify wrapper

0.2.5 2022-11-24 13:59 UTC

README

A simple wrapper to Dom Purify js library.

Check this page for more config options

Requirements

  • php: >=7.4
  • node: >=10.21.0

Installation

composer require freepik-labs/dom-purify

Usage

<?php
    use FreepikLabs\DomPurify\Purifier;

    $process = new Purifier;

    // Output will look like <svg><g></g></svg>
    $sanitized = $process->clean('<svg><g onload="alert(\'test\')"></g>', [
        'USE_PROFILES' => [
            'svg' => true
        ]
    ]);