0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-22 08:21:52 +00:00

[1.3.1] Added HTMLPurifier.func.php stub for a convenient function to call the library

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@598 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2006-12-06 22:04:16 +00:00
parent 301b2585ae
commit 4f8f022eac
3 changed files with 63 additions and 1 deletions

3
NEWS
View File

@ -13,7 +13,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
(major feature release)
1.3.1, unknown release date
(security/bugfix release)
(security/bugfix/minor feature release)
! Added HTMLPurifier.func.php stub for a convenient function to call the library
1.3.0, released 2006-11-26
# Invalid images are now removed, rather than replaced with a dud

View File

@ -0,0 +1,21 @@
<?php
/**
* Function wrapper for HTML Purifier for quick use.
* @note This function only includes the library when it is called. While
* this is efficient for instances when you only use HTML Purifier
* on a few of your pages, it murders bytecode caching. You still
* need to add HTML Purifier to your path.
*/
function HTMLPurifier($html, $config = null) {
static $purifier = false;
if (!$purifier) {
$init = true;
require_once 'HTMLPurifier.php';
$purifier = new HTMLPurifier();
}
return $purifier->purify($html, $config);
}
?>

40
smoketests/loadFunc.php Normal file
View File

@ -0,0 +1,40 @@
<?php
set_include_path('../library/' . PATH_SEPARATOR . get_include_path() );
header('Content-type: text/html; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
function printb($bool) {
echo '<strong>' . ($bool ? 'Pass' : 'Fail') . '</strong>';
}
function printEval($code) {
echo '<pre>' . htmlspecialchars($code) . '</pre>';
eval($code);
}
?><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>HTML Purifier Function Include Smoketest</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>HTML Purifier Function Include Smoketest</h1>
<p>Tests whether or not the includes are done properly and whether or
not the library is lazy loaded.</p>
<?php printEval("require_once 'HTMLPurifier.func.php';"); ?>
<p>HTMLPurifier class doesn't exist: <?php printb(!class_exists('HTMLPurifier')); ?></li></p>
<?php printEval("HTMLPurifier('foobar');"); ?>
<p>HTMLPurifier class exists: <?php printb(class_exists('HTMLPurifier')); ?></li></p>
</body>
</html>