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:
|
2007-05-29 21:31:24 +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
|
|
|
|