From 0bef01627117f00f36f1318b93b9e46914d04efc Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Fri, 16 May 2008 01:49:33 +0000 Subject: [PATCH] [3.1.0] Get testing working again for all versions - Standalone testing setup properly with autoload - Bootstrap autoloader deals more robustly with classes that don't exist, preventing class_exists($class, true) from barfing. - Cleanup $_reporter to $reporter git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1727 48356398-32a2-884e-a903-53898d9a118a --- NEWS | 3 +++ configdoc/usage.xml | 2 +- library/HTMLPurifier/Bootstrap.php | 12 +++++++----- tests/common.php | 2 +- tests/index.php | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index b314dac0..ca2777a2 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier ! %HTML.Allowed deals gracefully with whitespace anywhere, anytime! ! HTML Purifier's URI handling is a lot more robust, with much stricter validation checks and better percent encoding handling. +! Bootstrap autoloader deals more robustly with classes that don't exist, + preventing class_exists($class, true) from barfing. - InterchangeBuilder now alphabetizes its lists - Validation error in configdoc output fixed - Iconv and other encoding errors muted even with custom error handlers that @@ -50,6 +52,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier - Fatal error with unserialization of ScriptRequired - Created directories are now chmod'ed properly - Fixed bug with fallback languages in LanguageFactory +- Standalone testing setup properly with autoload . Out-of-date documentation revised . UTF-8 encoding check optimization as suggested by Diego . HTMLPurifier_Error removed in favor of exceptions diff --git a/configdoc/usage.xml b/configdoc/usage.xml index 0929548d..70da98fd 100644 --- a/configdoc/usage.xml +++ b/configdoc/usage.xml @@ -172,7 +172,7 @@ - 85 + 88 diff --git a/library/HTMLPurifier/Bootstrap.php b/library/HTMLPurifier/Bootstrap.php index 632ea75b..09dcb501 100644 --- a/library/HTMLPurifier/Bootstrap.php +++ b/library/HTMLPurifier/Bootstrap.php @@ -37,7 +37,7 @@ class HTMLPurifier_Bootstrap public static function autoload($class) { $file = HTMLPurifier_Bootstrap::getPath($class); if (!$file) return false; - require $file; + require HTMLPURIFIER_PREFIX . '/' . $file; return true; } @@ -48,11 +48,13 @@ class HTMLPurifier_Bootstrap if (strncmp('HTMLPurifier', $class, 12) !== 0) return false; // Custom implementations if (strncmp('HTMLPurifier_Language_', $class, 22) === 0) { - $code = str_replace('_', '-', substr($class, 22)); - return 'HTMLPurifier/Language/classes/' . $code . '.php'; + $code = str_replace('_', '-', substr($class, 22)); + $file = 'HTMLPurifier/Language/classes/' . $code . '.php'; + } else { + $file = str_replace('_', '/', $class) . '.php'; } - // Standard implementation - return str_replace('_', '/', $class) . '.php'; + if (!file_exists(HTMLPURIFIER_PREFIX . '/' . $file)) return false; + return $file; } /** diff --git a/tests/common.php b/tests/common.php index edea3a34..3b4838f1 100644 --- a/tests/common.php +++ b/tests/common.php @@ -193,7 +193,7 @@ class FailedTest extends UnitTestCase { } public function test() { $this->fail($this->msg); - if ($this->details) $this->_reporter->paintFormattedMessage($this->details); + if ($this->details) $this->reporter->paintFormattedMessage($this->details); } } diff --git a/tests/index.php b/tests/index.php index 172f4bea..4886732d 100755 --- a/tests/index.php +++ b/tests/index.php @@ -85,8 +85,8 @@ if ($AC['standalone']) { } else { require '../library/HTMLPurifier.path.php'; require 'HTMLPurifier.includes.php'; - require '../library/HTMLPurifier.autoload.php'; } +require '../library/HTMLPurifier.autoload.php'; require 'HTMLPurifier/Harness.php'; // Now, userland code begins to be executed