PHP Classes

PHP HTML Parser and Sanitizer: Parse and clean HTML code to keep secure tags

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 98 All time: 9,836 This week: 47Up
Version License PHP version Categories
html-sanitizer 1.0.0MIT/X Consortium ...7HTML, PHP 5, Security
Description 

Author

This package can parse and clean HTML code to keep only secure tags.

It can take a string with HTML code and parse it to keep only the tags it considers secure. But you can also define your custom whitelist.

It provides a base whitelist class that returns the values that should be considered secure, like protocols used in URLs and HTML tags and attributes.

Picture of Miraz Mac
  Performance   Level  
Innovation award
Innovation award
Nominee: 6x

 

Example

<?php

header
('Content-Type: text/html; charset=utf-8');

use
MirazMac\HtmlSanitizer\BasicWhitelist;
use
MirazMac\HtmlSanitizer\Sanitizer;
use
MirazMac\HtmlSanitizer\Whitelist;

require_once
'../vendor/autoload.php';

$whitelist = new BasicWhitelist;
$htmlsanitizer = new Sanitizer($whitelist);

//r($htmlsanitizer->getWhitelist());

$payload = file_get_contents('payload.txt');

echo
$htmlsanitizer->sanitize('<a href="#" download="true">Link</a>');


  Files folder image Files (12)  
File Role Description
Files folder imagebench (2 files)
Files folder imagesrc (4 files)
Files folder imagetests (1 file)
Files folder imageusage (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:98
This week:0
All time:9,836
This week:47Up