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:
|
|
|
|
$config->set('Core', 'Encoding', 'ISO-8859-1'); //replace with your encoding
|
|
|
|
$config->set('Core', 'XHTML', true); // set to false if HTML 4.01
|
|
|
|
|
|
|
|
$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
|
|
|
|
2006-08-14 02:57:16 +00:00
|
|
|
?>
|