mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-03 05:11:52 +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:
parent
35f8b3c801
commit
37b24b6732
9
NEWS
9
NEWS
@ -17,10 +17,14 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
HTMLPurifier.php is insufficient--in such cases include HTMLPurifier.autoload.php
|
HTMLPurifier.php is insufficient--in such cases include HTMLPurifier.autoload.php
|
||||||
as well to register our autoload handler (or modify your autoload function
|
as well to register our autoload handler (or modify your autoload function
|
||||||
to check HTMLPurifier_Bootstrap::getPath($class)).
|
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
|
! Extra utility classes for testing and non-library operations can
|
||||||
be found in extras/. Specifically, these are FSTools and ConfigSchema.
|
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
|
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
|
- Autoclose now operates iteratively, i.e. <span><span><div> now has
|
||||||
both span tags closed.
|
both span tags closed.
|
||||||
. Plugins now get their own changelogs according to project conventions.
|
. 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
|
. Implemented recursive glob at FSTools->globr
|
||||||
. ConfigSchema now has instance methods for all corresponding define*
|
. ConfigSchema now has instance methods for all corresponding define*
|
||||||
static methods.
|
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
|
3.0.0, released 2008-01-06
|
||||||
# HTML Purifier is PHP 5 only! The 2.1.x branch will be maintained
|
# HTML Purifier is PHP 5 only! The 2.1.x branch will be maintained
|
||||||
|
@ -8,6 +8,3 @@
|
|||||||
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
|
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
|
||||||
require_once 'HTMLPurifier/Bootstrap.php';
|
require_once 'HTMLPurifier/Bootstrap.php';
|
||||||
require_once 'HTMLPurifier.autoload.php';
|
require_once 'HTMLPurifier.autoload.php';
|
||||||
|
|
||||||
// This is temporary until we get pure autoload working
|
|
||||||
require_once 'HTMLPurifier.includes.php';
|
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
// Treat this file specially, as it is detached from the rest of the library
|
// Treat this file specially, as it is detached from the rest of the library
|
||||||
require_once 'HTMLPurifier/Bootstrap.php';
|
require_once 'HTMLPurifier/Bootstrap.php';
|
||||||
|
|
||||||
require 'HTMLPurifier/ConfigSchema.php';
|
|
||||||
require 'HTMLPurifier.php';
|
require 'HTMLPurifier.php';
|
||||||
require 'HTMLPurifier/AttrCollections.php';
|
require 'HTMLPurifier/AttrCollections.php';
|
||||||
require 'HTMLPurifier/AttrDef.php';
|
require 'HTMLPurifier/AttrDef.php';
|
||||||
@ -32,6 +31,8 @@ require 'HTMLPurifier/Definition.php';
|
|||||||
require 'HTMLPurifier/CSSDefinition.php';
|
require 'HTMLPurifier/CSSDefinition.php';
|
||||||
require 'HTMLPurifier/ChildDef.php';
|
require 'HTMLPurifier/ChildDef.php';
|
||||||
require 'HTMLPurifier/Config.php';
|
require 'HTMLPurifier/Config.php';
|
||||||
|
require 'HTMLPurifier/ConfigDef.php';
|
||||||
|
require 'HTMLPurifier/ConfigSchema.php';
|
||||||
require 'HTMLPurifier/ContentSets.php';
|
require 'HTMLPurifier/ContentSets.php';
|
||||||
require 'HTMLPurifier/Context.php';
|
require 'HTMLPurifier/Context.php';
|
||||||
require 'HTMLPurifier/DefinitionCache.php';
|
require 'HTMLPurifier/DefinitionCache.php';
|
||||||
@ -119,6 +120,9 @@ require 'HTMLPurifier/ChildDef/Required.php';
|
|||||||
require 'HTMLPurifier/ChildDef/Optional.php';
|
require 'HTMLPurifier/ChildDef/Optional.php';
|
||||||
require 'HTMLPurifier/ChildDef/StrictBlockquote.php';
|
require 'HTMLPurifier/ChildDef/StrictBlockquote.php';
|
||||||
require 'HTMLPurifier/ChildDef/Table.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/Decorator.php';
|
||||||
require 'HTMLPurifier/DefinitionCache/Null.php';
|
require 'HTMLPurifier/DefinitionCache/Null.php';
|
||||||
require 'HTMLPurifier/DefinitionCache/Serializer.php';
|
require 'HTMLPurifier/DefinitionCache/Serializer.php';
|
||||||
@ -143,8 +147,10 @@ require 'HTMLPurifier/HTMLModule/Text.php';
|
|||||||
require 'HTMLPurifier/HTMLModule/Tidy.php';
|
require 'HTMLPurifier/HTMLModule/Tidy.php';
|
||||||
require 'HTMLPurifier/HTMLModule/XMLCommonAttributes.php';
|
require 'HTMLPurifier/HTMLModule/XMLCommonAttributes.php';
|
||||||
require 'HTMLPurifier/HTMLModule/Tidy/Proprietary.php';
|
require 'HTMLPurifier/HTMLModule/Tidy/Proprietary.php';
|
||||||
require 'HTMLPurifier/HTMLModule/Tidy/XHTML.php';
|
|
||||||
require 'HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.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/AutoParagraph.php';
|
||||||
require 'HTMLPurifier/Injector/Linkify.php';
|
require 'HTMLPurifier/Injector/Linkify.php';
|
||||||
require 'HTMLPurifier/Injector/PurifierLinkify.php';
|
require 'HTMLPurifier/Injector/PurifierLinkify.php';
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
// constants are slow, but we'll make one exception
|
// constants are slow, but we'll make one exception
|
||||||
define('HTMLPURIFIER_PREFIX', dirname(__FILE__));
|
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.
|
* Facade that coordinates HTML Purifier's subsystems in order to purify HTML.
|
||||||
*
|
*
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class HTMLPurifier_HTMLModule_Tidy_Proprietary extends
|
class HTMLPurifier_HTMLModule_Tidy_Proprietary extends HTMLPurifier_HTMLModule_Tidy
|
||||||
HTMLPurifier_HTMLModule_Tidy
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public $name = 'Tidy_Proprietary';
|
public $name = 'Tidy_Proprietary';
|
||||||
|
19
library/HTMLPurifier/HTMLModule/Tidy/Strict.php
Normal file
19
library/HTMLPurifier/HTMLModule/Tidy/Strict.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
8
library/HTMLPurifier/HTMLModule/Tidy/Transitional.php
Normal file
8
library/HTMLPurifier/HTMLModule/Tidy/Transitional.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class HTMLPurifier_HTMLModule_Tidy_Transitional extends HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4
|
||||||
|
{
|
||||||
|
public $name = 'Tidy_Transitional';
|
||||||
|
public $defaultLevel = 'heavy';
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class HTMLPurifier_HTMLModule_Tidy_XHTML extends
|
class HTMLPurifier_HTMLModule_Tidy_XHTML extends HTMLPurifier_HTMLModule_Tidy
|
||||||
HTMLPurifier_HTMLModule_Tidy
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public $name = 'Tidy_XHTML';
|
public $name = 'Tidy_XHTML';
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends
|
class HTMLPurifier_HTMLModule_Tidy_XHTMLAndHTML4 extends HTMLPurifier_HTMLModule_Tidy
|
||||||
HTMLPurifier_HTMLModule_Tidy
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public function makeFixes() {
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -146,14 +146,14 @@ class HTMLPurifier_HTMLModuleManager
|
|||||||
$ok = false;
|
$ok = false;
|
||||||
foreach ($this->prefixes as $prefix) {
|
foreach ($this->prefixes as $prefix) {
|
||||||
$module = $prefix . $original_module;
|
$module = $prefix . $original_module;
|
||||||
if ($this->_classExists($module)) {
|
if (class_exists($module)) {
|
||||||
$ok = true;
|
$ok = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$ok) {
|
if (!$ok) {
|
||||||
$module = $original_module;
|
$module = $original_module;
|
||||||
if (!$this->_classExists($module)) {
|
if (!class_exists($module)) {
|
||||||
trigger_error($original_module . ' module does not exist',
|
trigger_error($original_module . ' module does not exist',
|
||||||
E_USER_ERROR);
|
E_USER_ERROR);
|
||||||
return;
|
return;
|
||||||
@ -168,15 +168,6 @@ class HTMLPurifier_HTMLModuleManager
|
|||||||
$this->registeredModules[$module->name] = $module;
|
$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,
|
* Adds a module to the current doctype by first registering it,
|
||||||
* and then tacking it on to the active doctype
|
* and then tacking it on to the active doctype
|
||||||
|
@ -18,13 +18,11 @@ $FS = new FSTools();
|
|||||||
$exclude_dirs = array(
|
$exclude_dirs = array(
|
||||||
'HTMLPurifier/Language/',
|
'HTMLPurifier/Language/',
|
||||||
'HTMLPurifier/Filter/',
|
'HTMLPurifier/Filter/',
|
||||||
'HTMLPurifier/ConfigDef/', // specially handled, remove this once fixed!
|
|
||||||
);
|
);
|
||||||
$exclude_files = array(
|
$exclude_files = array(
|
||||||
'HTMLPurifier/Lexer/PEARSax3.php',
|
'HTMLPurifier/Lexer/PEARSax3.php',
|
||||||
'HTMLPurifier/Lexer/PH5P.php',
|
'HTMLPurifier/Lexer/PH5P.php',
|
||||||
'HTMLPurifier/Bootstrap.php',
|
'HTMLPurifier/Bootstrap.php',
|
||||||
'HTMLPurifier/ConfigDef.php', // specially handled, remove this once fixed!
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Determine what files need to be included:
|
// Determine what files need to be included:
|
||||||
@ -65,9 +63,6 @@ function get_dependency_lookup($file) {
|
|||||||
$deps = array();
|
$deps = array();
|
||||||
while (!feof($fh)) {
|
while (!feof($fh)) {
|
||||||
$line = fgets($fh);
|
$line = fgets($fh);
|
||||||
if (strncmp('HTMLPurifier_ConfigSchema', $line, 25) === 0) {
|
|
||||||
$deps['HTMLPurifier/ConfigSchema.php'] = true;
|
|
||||||
}
|
|
||||||
if (strncmp('class', $line, 5) === 0) {
|
if (strncmp('class', $line, 5) === 0) {
|
||||||
// The implementation here is fragile and will break if we attempt
|
// The implementation here is fragile and will break if we attempt
|
||||||
// to use interfaces. Beware!
|
// to use interfaces. Beware!
|
||||||
|
@ -145,6 +145,7 @@ $FS->rmdirr('standalone'); // ensure a clean copy
|
|||||||
// data files
|
// data files
|
||||||
$FS->mkdirr('standalone/HTMLPurifier/DefinitionCache/Serializer');
|
$FS->mkdirr('standalone/HTMLPurifier/DefinitionCache/Serializer');
|
||||||
make_dir_standalone('HTMLPurifier/EntityLookup');
|
make_dir_standalone('HTMLPurifier/EntityLookup');
|
||||||
|
make_file_standalone('HTMLPurifier/ConfigSchema/schema.ser');
|
||||||
|
|
||||||
// non-standard inclusion setup
|
// non-standard inclusion setup
|
||||||
make_dir_standalone('HTMLPurifier/Language');
|
make_dir_standalone('HTMLPurifier/Language');
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
define('HTMLPurifierTest', 1);
|
define('HTMLPurifierTest', 1);
|
||||||
define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas
|
define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas
|
||||||
|
chdir(dirname(__FILE__));
|
||||||
|
|
||||||
require_once 'common.php';
|
require_once 'common.php';
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ if ($AC['standalone']) {
|
|||||||
require_once '../library/HTMLPurifier.standalone.php';
|
require_once '../library/HTMLPurifier.standalone.php';
|
||||||
} else {
|
} else {
|
||||||
set_include_path(realpath('../library') . PATH_SEPARATOR . get_include_path() );
|
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';
|
require_once 'HTMLPurifier/Harness.php';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user