2007-04-30 00:53:13 +00:00
|
|
|
<?php
|
2006-08-14 02:57:16 +00:00
|
|
|
|
|
|
|
// This file demonstrates basic usage of HTMLPurifier.
|
|
|
|
|
2007-04-30 00:53:13 +00:00
|
|
|
// replace this with the path to the HTML Purifier library
|
|
|
|
require_once '../../library/HTMLPurifier.auto.php';
|
2006-08-14 02:57:16 +00:00
|
|
|
|
2007-04-30 00:53:13 +00:00
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
|
|
|
|
|
|
|
// configuration goes here:
|
2009-02-20 00:17:49 +00:00
|
|
|
$config->set('Core.Encoding', 'UTF-8'); // replace with your encoding
|
|
|
|
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional'); // replace with your doctype
|
2007-04-30 00:53:13 +00:00
|
|
|
|
|
|
|
$purifier = new HTMLPurifier($config);
|
|
|
|
|
|
|
|
// untrusted input HTML
|
2006-08-14 02:57:16 +00:00
|
|
|
$html = '<b>Simple and short';
|
|
|
|
|
|
|
|
$pure_html = $purifier->purify($html);
|
|
|
|
|
2007-04-30 00:53:13 +00:00
|
|
|
echo '<pre>' . htmlspecialchars($pure_html) . '</pre>';
|
2007-01-11 22:37:54 +00:00
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|