PHPackages                             ipedis/file-sanitizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ipedis/file-sanitizer

ActiveLibrary

ipedis/file-sanitizer
=====================

2.1.0(3mo ago)03↑2900%1PHPPHP &gt;=8.1CI passing

Since Jun 7Pushed 1mo agoCompare

[ Source](https://github.com/ipedis/file-sanitizer)[ Packagist](https://packagist.org/packages/ipedis/file-sanitizer)[ RSS](/packages/ipedis-file-sanitizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (6)Used By (1)

File Sanitizer
==============

[](#file-sanitizer)

[![CI](https://github.com/ipedis/file-sanitizer/actions/workflows/ci.yml/badge.svg)](https://github.com/ipedis/file-sanitizer/actions/workflows/ci.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/8032d1d776e284b4825d32af8ae764b81af494fd7475cc88bd659ed1eb62854c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6970656469732f66696c652d73616e6974697a65722e737667)](https://packagist.org/packages/ipedis/file-sanitizer)[![PHP Version](https://camo.githubusercontent.com/39953833c6501d14a42847aa55343981941382302ffcedc86523b742a84c4d8c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6970656469732f66696c652d73616e6974697a65722e737667)](https://packagist.org/packages/ipedis/file-sanitizer)[![License](https://camo.githubusercontent.com/5082149b060d6867a7956806cde1bea4deaba0879af947a2edc3d4e1c28847fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6970656469732f66696c652d73616e6974697a65722e737667)](https://packagist.org/packages/ipedis/file-sanitizer)

Pipeline-based HTML and XML sanitizer for PHP. Removes script tags, event handlers, PHP tags, CDATA injections, and other XSS vectors through a configurable chain of cleanup steps.

Installation
------------

[](#installation)

```
composer require ipedis/file-sanitizer
```

Quick Start
-----------

[](#quick-start)

```
use Ipedis\FileSanitizer\Sanitizer\Sanitize;

$sanitizer = new Sanitize(type: 'html');
$result = $sanitizer->process('evil()Hello');

echo $result->getContent(); // Hello
```

### XML sanitization

[](#xml-sanitization)

```
$sanitizer = new Sanitize(type: 'xml');
$result = $sanitizer->process($xmlContent);
```

### Custom configuration

[](#custom-configuration)

```
use Ipedis\FileSanitizer\Configuration\Configuration;
use Ipedis\FileSanitizer\Pipeline\Steps\PhpTagCleanupStep;

// Skip specific steps
$config = new Configuration(
    ignoredSteps: [PhpTagCleanupStep::class],
);

$sanitizer = new Sanitize(type: 'html', configuration: $config);
```

### Custom cleanup steps

[](#custom-cleanup-steps)

```
use Ipedis\FileSanitizer\Pipeline\Steps\CleanupStepAbstract;
use Ipedis\FileSanitizer\Pipeline\Payload;

class MyCustomStep extends CleanupStepAbstract
{
    protected function process(Payload $payload): Payload
    {
        $content = preg_replace('/pattern/', '', $payload->getContent());
        return $payload->setContent($content);
    }
}

$config = new Configuration(customSteps: [MyCustomStep::class]);
$sanitizer = new Sanitize(type: 'html', configuration: $config);
```

Cleanup Steps
-------------

[](#cleanup-steps)

### HTML pipeline

[](#html-pipeline)

StepWhat it removes`DecodeTagCleanupStep`Decodes HTML entities (`&lt;script&gt;` → ``)`PhpTagCleanupStep`PHP tags (``)`ScriptTagCleanupStep``` blocks`AttributeCleanupStep`Event handlers (`onclick`, `onerror`...) and `javascript:` URLs`StyleTagCleanupStep``` blocks containing JavaScript### XML pipeline

[](#xml-pipeline)

StepWhat it removes`DecodeTagCleanupStep`Decodes HTML entities`CdataTagCleanupStep`CDATA injection patterns`ScriptTagCleanupStep``` blocksCompatibility
-------------

[](#compatibility)

PHPStatus8.2✅8.3✅8.4✅8.5✅Local Development
-----------------

[](#local-development)

Requires [Docker](https://www.docker.com/).

```
make up        # Start container
make install   # Install dependencies
make qa        # Run full QA suite (rector + pint + phpstan + tests)
```

Available targets:

CommandDescription`make up`Start container`make down`Stop container`make install`Install Composer dependencies`make update`Update Composer dependencies`make test`Run PHPUnit tests`make phpstan`Run static analysis (level max)`make pint`Fix code style (PSR-12)`make rector`Run automated refactoring`make qa`Run all checks`make shell`Open container shellDisclaimer
----------

[](#disclaimer)

This package is maintained by [Ipedis](https://www.ipedis.com). It is provided as-is under the terms of its license.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance87

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~669 days

Total

3

Last Release

95d ago

Major Versions

1.0.0 → 2.0.02022-06-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/97cc863f90ac18a7a620893a0a9cbf099dab4f8e5f853e1fe5a28c64b6dec9cc?d=identicon)[yanis-git](/maintainers/yanis-git)

---

Top Contributors

[![MelchiorIpedis](https://avatars.githubusercontent.com/u/126576609?v=4)](https://github.com/MelchiorIpedis "MelchiorIpedis (6 commits)")[![yanis-git](https://avatars.githubusercontent.com/u/4113879?v=4)](https://github.com/yanis-git "yanis-git (2 commits)")[![tejaskgosai](https://avatars.githubusercontent.com/u/126658306?v=4)](https://github.com/tejaskgosai "tejaskgosai (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisRector

### Embed Badge

![Health badge](/badges/ipedis-file-sanitizer/health.svg)

```
[![Health](https://phpackages.com/badges/ipedis-file-sanitizer/health.svg)](https://phpackages.com/packages/ipedis-file-sanitizer)
```

###  Alternatives

[hisorange/browser-detect

Browser &amp; Mobile detection package for Laravel.

1.1k10.1M50](/packages/hisorange-browser-detect)[concrete5/core

Concrete core subtree split

19159.3k48](/packages/concrete5-core)[beacon-hq/bag

A comprehensive immutable value objects implementation

1789.1k3](/packages/beacon-hq-bag)[phuml/phuml

phUML is a fully automatic UML class diagram generator for PHP code

11411.3k1](/packages/phuml-phuml)[synolia/sylius-akeneo-plugin

Akeneo connector for Sylius.

2696.0k](/packages/synolia-sylius-akeneo-plugin)[refinery29/piston

Opinionated Micro Framework for APIs

1936.8k](/packages/refinery29-piston)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
