mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 08:21:52 +00:00
All PHPT tests for now complete! Fix an SPL autoload bug.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1564 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
969a027a5b
commit
a4abc45505
6
TODO
6
TODO
@ -16,11 +16,6 @@ UPCOMING RELEASE
|
||||
----------------
|
||||
|
||||
IMPORTANT
|
||||
- Test HTMLPurifier.auto.php, HTMLPurifier.includes.php, and combinations
|
||||
of the two. This is related to standalone in tests/index.php. This should use
|
||||
semi-automated smoketests using PHPT style files (probably should be part
|
||||
of SimpleTest framework). These tests can be further extended to work for
|
||||
many of our other smoketests. Follow the documentation!
|
||||
- Release candidate, because of the major changes
|
||||
- Move utility classes for ConfigSchema into HTML Purifier itself: they're
|
||||
that important
|
||||
@ -144,6 +139,7 @@ Unknown release (on a scratch-an-itch basis)
|
||||
- Allow scoped="scoped" attribute in <style> tags; may be troublesome
|
||||
because regular CSS has no way of uniquely identifying nodes, so we'd
|
||||
have to generate IDs
|
||||
- Time PHPT tests
|
||||
|
||||
Requested
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
if (function_exists('spl_autoload_register')) {
|
||||
spl_autoload_register(array('HTMLPurifier_Bootstrap', 'autoload'));
|
||||
HTMLPurifier_Bootstrap::registerAutoload();
|
||||
if (function_exists('__autoload')) {
|
||||
// Be polite and ensure that userland autoload gets retained
|
||||
spl_autoload_register('__autoload');
|
||||
|
@ -55,4 +55,18 @@ class HTMLPurifier_Bootstrap
|
||||
return str_replace('_', '/', $class) . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* "Pre-registers" our autoloader on the SPL stack.
|
||||
*/
|
||||
public static function registerAutoload() {
|
||||
$autoload = array('HTMLPurifier_Bootstrap', 'autoload');
|
||||
if ( ($funcs = spl_autoload_functions()) === false ) {
|
||||
spl_autoload_register($autoload);
|
||||
} else {
|
||||
foreach ($funcs as $func) spl_autoload_unregister($func);
|
||||
spl_autoload_register($autoload);
|
||||
foreach ($funcs as $func) spl_autoload_register($func);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
<?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>
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
// this file is encoded in UTF-8, please don't let your editor mangle it
|
||||
|
||||
require_once 'common.php';
|
||||
|
||||
echo '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||
?><!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>HTML Purifier UTF-8 Smoketest</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>HTML Purifier UTF-8 Smoketest</h1>
|
||||
<?php
|
||||
|
||||
$purifier = new HTMLPurifier();
|
||||
$string = '
|
||||
<ul>
|
||||
<li><b>Chinese</b> - 太極拳</li>
|
||||
<li><b>Russian</b> - ЊЎЖ</li>
|
||||
<li><b>Arabic</b> - لمنس</li>
|
||||
</ul>
|
||||
';
|
||||
|
||||
?>
|
||||
<h2>Raw</h2>
|
||||
<?php echo $string; ?>
|
||||
<h2>Purified</h2>
|
||||
<?php echo $purifier->purify($string); ?>
|
||||
<h2>Analysis</h2>
|
||||
<p>The content in <strong>Raw</strong> should be equivalent to the content
|
||||
in <strong>Purified</strong>. If <strong>Purified</strong> is mangled, there
|
||||
is likely trouble a-brewing in the library. If
|
||||
both are mangled, check to see that this file was not corrupted.</p>
|
||||
</body>
|
||||
</html>
|
9
tests/HTMLPurifier/PHPT/func.phpt
Normal file
9
tests/HTMLPurifier/PHPT/func.phpt
Normal file
@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
HTMLPurifier.func.php test
|
||||
--FILE--
|
||||
<?php
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
require 'HTMLPurifier.func.php';
|
||||
echo HTMLPurifier('<b>Salsa!');
|
||||
--EXPECT--
|
||||
<b>Salsa!</b>
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
HTMLPurifier.auto.php using spl_autoload_register with userland __autoload loading test
|
||||
HTMLPurifier.auto.php using spl_autoload_register with user registration loading test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists('spl_autoload_register')) {
|
||||
@ -7,10 +7,12 @@ if (!function_exists('spl_autoload_register')) {
|
||||
}
|
||||
--FILE--
|
||||
<?php
|
||||
function __autoload($class) {
|
||||
function my_autoload($class) {
|
||||
echo "Autoloading $class..." . PHP_EOL;
|
||||
eval("class $class {}");
|
||||
return true;
|
||||
}
|
||||
spl_autoload_register('my_autoload');
|
||||
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
9
tests/HTMLPurifier/PHPT/utf8.phpt
Normal file
9
tests/HTMLPurifier/PHPT/utf8.phpt
Normal file
@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
UTF-8 smoketest
|
||||
--FILE--
|
||||
<?php
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
$purifier = new HTMLPurifier();
|
||||
echo $purifier->purify('太極拳, ЊЎЖ, لمنس');
|
||||
--EXPECT--
|
||||
太極拳, ЊЎЖ, لمنس
|
Loading…
Reference in New Issue
Block a user