Skip to content

Instantly share code, notes, and snippets.

@Scroller
Scroller / HtmlFilter.php
Created January 7, 2012 17:51
Sanitizing HTML 'parser'
<?php
class HtmlFilter{ //Version: 3.1
const OPENS = 1;
const CLOSES = 2;
const SINGLE = 3;
public $goodTagsRE = 'i|b|a|em|strong|hr|ul|ol|li|img';
public $goodAttrs = array('href', 'src', 'class', 'alt', 'title');
public $goodProtocolsRE = 'https?|s?ftp|mailto|torrent';
public $defaultProtocol = 'http://'; //prepended to URLs without above protocols