Search by

pieceofcake2 / purifiable

ttsuru

CakePHP 2 behavior that sanitizes model data with HTML Purifier

Package info

github.com/pieceofcake2/purifiable

Type:cakephp-plugin

pkg:composer/pieceofcake2/purifiable

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

v1.0.1 2026-10-16 08:35 UTC

README

GitHub License Packagist Version PHP CakePHP PHPStan CI Codecov

This is forked for CakePHP2.

A model behavior for pieceofcake2/cakephp applications that sanitizes HTML fields with HTML Purifier before they are saved: it removes malicious code (XSS) and keeps the allowed formatting.

Documentation

It covers the settings, the HTML Purifier configuration, custom filters, the definition cache and the migration from josegonzalez/cakephp-purifiable.

The Markdown documentation is also included in the Composer package, in the plugin's directory: plugins/Purifiable/docs/README.md (the location depends on your installer-paths).

Requirements

  • PHP 8.0+
  • pieceofcake2/cakephp 2.12+
  • ezyang/htmlpurifier 4.17+ (installed with the plugin)

Installation

composer require pieceofcake2/purifiable

Load the plugin in config/bootstrap.php (legacy layout: app/Config/bootstrap.php):

CakePlugin::load('Purifiable');

See Installation for the installer-paths setting.

Usage

class Post extends AppModel
{
    public $actsAs = [
        'Purifiable.Purifiable' => [
            'fields' => ['body'],
            'overwrite' => true,
        ],
    ];
}

body is purified when the post is saved. Without overwrite, the original value is kept and the purified HTML is saved to body_clean. See Settings.

Contributing

See the contribution guidelines.

Origin

This package is a maintained fork of josegonzalez/cakephp-purifiable (josegonzalez/cakephp-purifiable on Packagist, archived), originally by Jose Diaz-Gonzalez. It is maintained for CakePHP 2 on modern PHP by pieceofcake2. Changes from the original are listed in the commit history since the fork.

License

Licensed under the MIT License. See LICENSE.