0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-09-18 18:25:18 +00:00

[3.1.0] Further cleanup, making standalone work again

- Remove includes call in HTMLPurifier.auto.php
- Relax ConfigSchema treatment in generate-includes.php
- Clean up some empty comments (there are probably more)
- De-indent some extends
- class_exists() should now attempt to use autoload
- schema.ser is now a standalone file
- tests/index.php can be run from any directory

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1540 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2008-02-10 21:34:52 +00:00
parent 35f8b3c801
commit 37b24b6732
13 changed files with 51 additions and 56 deletions

9
NEWS
View File

@ -17,10 +17,14 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
HTMLPurifier.php is insufficient--in such cases include HTMLPurifier.autoload.php
as well to register our autoload handler (or modify your autoload function
to check HTMLPurifier_Bootstrap::getPath($class)).
# HTMLPurifier_ConfigSchema static functions are officially deprecated. Schema
information is stored in the ConfigSchema directory, and the
maintenance/generate-schema-cache.php generates the schema.ser file, which
is now instantiated. Support for userland schema changes coming soon!
! Extra utility classes for testing and non-library operations can
be found in extras/. Specifically, these are FSTools and ConfigSchema.
You may find a use for these in your own project, but right now they
are highly experimental.
are highly experimental and volatile.
- Autoclose now operates iteratively, i.e. <span><span><div> now has
both span tags closed.
. Plugins now get their own changelogs according to project conventions.
@ -31,6 +35,9 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
. Implemented recursive glob at FSTools->globr
. ConfigSchema now has instance methods for all corresponding define*
static methods.
. A couple of new historical maintenance scripts were added.
. HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php split into two files
. tests/index.php can now be run from any directory.
3.0.0, released 2008-01-06
# HTML Purifier is PHP 5 only! The 2.1.x branch will be maintained

View File

@ -8,6 +8,3 @@
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once 'HTMLPurifier/Bootstrap.php';
require_once 'HTMLPurifier.autoload.php';
// This is temporary until we get pure autoload working
require_once 'HTMLPurifier.includes.php';

View File

@ -21,7 +21,6 @@
// Treat this file specially, as it is detached from the rest of the library
require_once 'HTMLPurifier/Bootstrap.php';
require 'HTMLPurifier/ConfigSchema.php';
require 'HTMLPurifier.php';
require 'HTMLPurifier/AttrCollections.php';
require 'HTMLPurifier/AttrDef.php';
@ -32,6 +31,8 @@ require 'HTMLPurifier/Definition.php';
require 'HTMLPurifier/CSSDefinition.php';
require 'HTMLPurifier/ChildDef.php';
require 'HTMLPurifier/Config.php';
require 'HTMLPurifier/ConfigDef.php';
require 'HTMLPurifier/ConfigSchema.php';
require 'HTMLPurifier/ContentSets.php';
require 'HTMLPurifier/Context.php';
require 'HTMLPurifier/DefinitionCache.php';
@ -119,6 +120,9 @@ require 'HTMLPurifier/ChildDef/Required.php';
require 'HTMLPurifier/ChildDef/Optional.php';
require 'HTMLPurifier/ChildDef/StrictBlockquote.php';
require 'HTMLPurifier/ChildDef/Table.php';
require 'HTMLPurifier/ConfigDef/Directive.php';
require 'HTMLPurifier/ConfigDef/DirectiveAlias.php';
require 'HTMLPurifier/ConfigDef/Namespace.php';
require 'HTMLPurifier/DefinitionCache/Decorator.php';
require 'HTMLPurifier/DefinitionCache/Null.php';
require 'HTMLPurifier/DefinitionCache/Serializer.php';
@ -143,8 +147,10 @@ require 'HTMLPurifier/HTMLModule/Text.php';
require 'HTMLPurifier/HTMLModule/Tidy.php';
require 'HTMLPurifier/HTMLModule/XMLCommonAttributes.php';
require 'HTMLPurifier/HTMLModule/Tidy/Proprietary.php';
require 'HTMLPurifier/HTMLModule/Tidy/XHTML.php';
require 'HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php';
require 'HTMLPurifier/HTMLModule/Tidy/Strict.php';
require 'HTMLPurifier/HTMLModule/Tidy/Transitional.php';
require 'HTMLPurifier/HTMLModule/Tidy/XHTML.php';
require 'HTMLPurifier/Injector/AutoParagraph.php';
require 'HTMLPurifier/Injector/Linkify.php';
require 'HTMLPurifier/Injector/PurifierLinkify.php';

View File

@ -42,7 +42,6 @@
// constants are slow, but we'll make one exception
define('HTMLPURIFIER_PREFIX', dirname(__FILE__));
// every class has an undocumented dependency to these, must be included!
/**
* Facade that coordinates HTML Purifier's subsystems in order to purify HTML.
*

View File

@ -1,7 +1,6 @@
<?php
class HTMLPurifier_HTMLModule_Tidy_Proprietary extends
HTMLPurifier_HTMLModule_Tidy
class HTMLPurifier_HTMLModule_Tidy_Proprietary extends HTMLPurifier_HTMLModule_Tidy
{
public $name = 'Tidy_Proprietary';

View File

@ -0,0 +1,19 @@
<?php
class HTMLPurifier_HTMLModule_Tidy_Strict extends HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4
{
public $name = 'Tidy_Strict';
public $defaultLevel = 'light';
public function makeFixes() {
$r = parent::makeFixes();
$r['blockquote#content_model_type'] = 'strictblockquote';
return $r;
}
public $defines_child_def = true;
public function getChildDef($def) {
if ($def->content_model_type != 'strictblockquote') return parent::getChildDef($def);
return new HTMLPurifier_ChildDef_StrictBlockquote($def->content_model);
}
}

View File

@ -0,0 +1,8 @@
<?php
class HTMLPurifier_HTMLModule_Tidy_Transitional extends HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4
{
public $name = 'Tidy_Transitional';
public $defaultLevel = 'heavy';
}

View File

@ -1,7 +1,6 @@
<?php
class HTMLPurifier_HTMLModule_Tidy_XHTML extends
HTMLPurifier_HTMLModule_Tidy
class HTMLPurifier_HTMLModule_Tidy_XHTML extends HTMLPurifier_HTMLModule_Tidy
{
public $name = 'Tidy_XHTML';

View File

@ -1,7 +1,6 @@
<?php
class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends
HTMLPurifier_HTMLModule_Tidy
class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends HTMLPurifier_HTMLModule_Tidy
{
public function makeFixes() {
@ -163,29 +162,3 @@ class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends
}
class HTMLPurifier_HTMLModule_Tidy_Transitional extends
HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4
{
public $name = 'Tidy_Transitional';
public $defaultLevel = 'heavy';
}
class HTMLPurifier_HTMLModule_Tidy_Strict extends
HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4
{
public $name = 'Tidy_Strict';
public $defaultLevel = 'light';
public function makeFixes() {
$r = parent::makeFixes();
$r['blockquote#content_model_type'] = 'strictblockquote';
return $r;
}
public $defines_child_def = true;
public function getChildDef($def) {
if ($def->content_model_type != 'strictblockquote') return parent::getChildDef($def);
return new HTMLPurifier_ChildDef_StrictBlockquote($def->content_model);
}
}

View File

@ -146,14 +146,14 @@ class HTMLPurifier_HTMLModuleManager
$ok = false;
foreach ($this->prefixes as $prefix) {
$module = $prefix . $original_module;
if ($this->_classExists($module)) {
if (class_exists($module)) {
$ok = true;
break;
}
}
if (!$ok) {
$module = $original_module;
if (!$this->_classExists($module)) {
if (!class_exists($module)) {
trigger_error($original_module . ' module does not exist',
E_USER_ERROR);
return;
@ -168,15 +168,6 @@ class HTMLPurifier_HTMLModuleManager
$this->registeredModules[$module->name] = $module;
}
/**
* Safely tests for class existence without invoking __autoload in PHP5
* or greater.
* @param $name String class name to test
*/
private function _classExists($name) {
return class_exists($name, false);
}
/**
* Adds a module to the current doctype by first registering it,
* and then tacking it on to the active doctype

View File

@ -18,13 +18,11 @@ $FS = new FSTools();
$exclude_dirs = array(
'HTMLPurifier/Language/',
'HTMLPurifier/Filter/',
'HTMLPurifier/ConfigDef/', // specially handled, remove this once fixed!
);
$exclude_files = array(
'HTMLPurifier/Lexer/PEARSax3.php',
'HTMLPurifier/Lexer/PH5P.php',
'HTMLPurifier/Bootstrap.php',
'HTMLPurifier/ConfigDef.php', // specially handled, remove this once fixed!
);
// Determine what files need to be included:
@ -65,9 +63,6 @@ function get_dependency_lookup($file) {
$deps = array();
while (!feof($fh)) {
$line = fgets($fh);
if (strncmp('HTMLPurifier_ConfigSchema', $line, 25) === 0) {
$deps['HTMLPurifier/ConfigSchema.php'] = true;
}
if (strncmp('class', $line, 5) === 0) {
// The implementation here is fragile and will break if we attempt
// to use interfaces. Beware!

View File

@ -145,6 +145,7 @@ $FS->rmdirr('standalone'); // ensure a clean copy
// data files
$FS->mkdirr('standalone/HTMLPurifier/DefinitionCache/Serializer');
make_dir_standalone('HTMLPurifier/EntityLookup');
make_file_standalone('HTMLPurifier/ConfigSchema/schema.ser');
// non-standard inclusion setup
make_dir_standalone('HTMLPurifier/Language');

View File

@ -15,6 +15,7 @@
define('HTMLPurifierTest', 1);
define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas
chdir(dirname(__FILE__));
require_once 'common.php';
@ -52,7 +53,7 @@ if ($AC['standalone']) {
require_once '../library/HTMLPurifier.standalone.php';
} else {
set_include_path(realpath('../library') . PATH_SEPARATOR . get_include_path() );
require_once 'HTMLPurifier.includes.php';
require_once 'HTMLPurifier.auto.php';
}
require_once 'HTMLPurifier/Harness.php';