this library is useful to clean the contents of a file, against xss attacks and malicious codes.
File supported currently : html and xml.
use the service Sanitize.
$sanitize = new Sanitize(type: 'html' );
$dirty = 'dircty content';
$sanitized = $sanitize->process($dirty);Advanced:
we can configure the sanitizer using the class configuration to ignore some cleanupSteps or add customSteps .
$configuration = new Configuration(
ignoredSteps: [CdataTagCleanupStep::class, DomPurifierCleanupStep::class],
);
$sanitize = new Sanitize(type: 'html', configuration: $configuration);./vendor/bin/phpunit tests/SanitizeTest.php
We can play around data, input should be same of output after clean up.
NB: need to update data provider on tests/SanitizeTest.php
if you want to add some test file