mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 16:31:53 +00:00
[2.1.2] Fix problems with standalone distribution, change smoketests so that it's easier to test the standalone.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1388 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
6f6fcbc354
commit
d75c695994
1
NEWS
1
NEWS
@ -24,6 +24,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
default for tables in most browsers. Thanks Brett Zamir for pointing
|
||||
this out.
|
||||
- Fix validation errors in configuration form
|
||||
- Hammer out a bunch of edge-case bugs in the standalone distribution
|
||||
. Unit test refactoring for one logical test per test function
|
||||
. Config and context parameters in ComplexHarness deprecated: instead, edit
|
||||
the $config and $context member variables
|
||||
|
@ -84,7 +84,7 @@ function mkdir_deep($folder) {
|
||||
function copyr($source, $dest) {
|
||||
// Simple copy for a file
|
||||
if (is_file($source)) {
|
||||
return copy($source, $dest);
|
||||
return copy_and_remove_includes($source, $dest);
|
||||
}
|
||||
// Make destination directory
|
||||
if (!is_dir($dest)) {
|
||||
@ -158,7 +158,14 @@ function make_dir_standalone($dir) {
|
||||
|
||||
function make_file_standalone($file) {
|
||||
mkdir_deep('standalone/' . dirname($file));
|
||||
return copy($file, 'standalone/' . $file);
|
||||
copy_and_remove_includes($file, 'standalone/' . $file);
|
||||
return true;
|
||||
}
|
||||
|
||||
function copy_and_remove_includes($file, $sfile) {
|
||||
$contents = file_get_contents($file);
|
||||
if (strrchr($file, '.') === '.php') $contents = replace_includes($contents);
|
||||
return file_put_contents($sfile, $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,7 +175,7 @@ function make_file_standalone($file) {
|
||||
function replace_includes_callback($matches) {
|
||||
$file = $matches[1];
|
||||
// PHP 5 only file
|
||||
if ($file == 'HTMLPurifier/Lexer/DOMLex.php') {
|
||||
if ($file == 'HTMLPurifier/Lexer/DOMLex.php' || $file == 'HTMLPurifier/Printer.php') {
|
||||
return $matches[0];
|
||||
}
|
||||
if (isset($GLOBALS['loaded'][$file])) return '';
|
||||
@ -196,12 +203,12 @@ rmdirr('standalone'); // ensure a clean copy
|
||||
mkdir_deep('standalone/HTMLPurifier/DefinitionCache/Serializer');
|
||||
make_dir_standalone('HTMLPurifier/EntityLookup');
|
||||
make_dir_standalone('HTMLPurifier/Language');
|
||||
make_file_standalone('HTMLPurifier/Printer/ConfigForm.js');
|
||||
make_file_standalone('HTMLPurifier/Printer/ConfigForm.css');
|
||||
make_file_standalone('HTMLPurifier/Printer.php');
|
||||
make_dir_standalone('HTMLPurifier/Printer');
|
||||
make_dir_standalone('HTMLPurifier/URIScheme');
|
||||
// PHP 5 only file
|
||||
mkdir_deep('standalone/HTMLPurifier/Lexer');
|
||||
make_dir_standalone('HTMLPurifier/Filter');
|
||||
// PHP 5 only files
|
||||
make_file_standalone('HTMLPurifier/Lexer/DOMLex.php');
|
||||
make_file_standalone('HTMLPurifier/TokenFactory.php');
|
||||
make_file_standalone('HTMLPurifier/Lexer/PH5P.php');
|
||||
echo ' done!' . PHP_EOL;
|
||||
|
||||
|
@ -31,7 +31,7 @@ while (false !== ($filename = readdir($dh))) {
|
||||
if ($filename == 'all.php') continue;
|
||||
if ($filename == 'testSchema.php') continue;
|
||||
?>
|
||||
<iframe src="<?php echo escapeHTML($filename); ?>"></iframe>
|
||||
<iframe src="<?php echo escapeHTML($filename); if (isset($_GET['standalone'])) {echo '?standalone';} ?>"></iframe>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,11 @@
|
||||
|
||||
header('Content-type: text/html; charset=UTF-8');
|
||||
|
||||
if (!isset($_GET['standalone'])) {
|
||||
require_once '../library/HTMLPurifier.auto.php';
|
||||
} else {
|
||||
require_once '../library/HTMLPurifier.standalone.php';
|
||||
}
|
||||
error_reporting(E_ALL);
|
||||
|
||||
function escapeHTML($string) {
|
||||
|
Loading…
Reference in New Issue
Block a user