From d75c69599466d4beafb278ebf93a48da55a6a4ba Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 19 Aug 2007 21:38:19 +0000 Subject: [PATCH] [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 --- NEWS | 1 + maintenance/merge-library.php | 23 +++++++++++++++-------- smoketests/all.php | 2 +- smoketests/common.php | 6 +++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index a28f0f77..ac6ffa5c 100644 --- a/NEWS +++ b/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 diff --git a/maintenance/merge-library.php b/maintenance/merge-library.php index 46c3c891..4ee7d3f0 100755 --- a/maintenance/merge-library.php +++ b/maintenance/merge-library.php @@ -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; diff --git a/smoketests/all.php b/smoketests/all.php index 3f514e84..b17ce22b 100644 --- a/smoketests/all.php +++ b/smoketests/all.php @@ -31,7 +31,7 @@ while (false !== ($filename = readdir($dh))) { if ($filename == 'all.php') continue; if ($filename == 'testSchema.php') continue; ?> - +