mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00:00
[1.7.0] Code audit
- Add set accessor, update access control on variables in AttrTypes - Add warning notes to non-unit tested, out of date or unused code files - Remove redundant include in EntityParser, expand string regexp to match all ASCII XML-style entities - Remove obsolete hooks in HTMLModule git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1078 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
3f06d8316c
commit
fda2043ace
@ -16,12 +16,13 @@ class HTMLPurifier_AttrTypes
|
||||
{
|
||||
/**
|
||||
* Lookup array of attribute string identifiers to concrete implementations
|
||||
* @public
|
||||
* @protected
|
||||
*/
|
||||
var $info = array();
|
||||
|
||||
/**
|
||||
* Constructs the info array
|
||||
* Constructs the info array, supplying default implementations for attribute
|
||||
* types.
|
||||
*/
|
||||
function HTMLPurifier_AttrTypes() {
|
||||
$this->info['CDATA'] = new HTMLPurifier_AttrDef_Text();
|
||||
@ -40,15 +41,27 @@ class HTMLPurifier_AttrTypes
|
||||
|
||||
/**
|
||||
* Retrieves a type
|
||||
* @param $type String type name
|
||||
* @return Object AttrDef for type
|
||||
*/
|
||||
function get($type) {
|
||||
// maybe some extra initialization could be done
|
||||
// If $type is complicated, we may to clone the attribute
|
||||
// definition and make custom changes
|
||||
if (!isset($this->info[$type])) {
|
||||
trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
|
||||
return;
|
||||
}
|
||||
return $this->info[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new implementation for a type
|
||||
* @param $type String type name
|
||||
* @param $impl Object AttrDef for type
|
||||
*/
|
||||
function set($type, $impl) {
|
||||
$this->info[$type] = $impl;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -6,6 +6,8 @@ require_once 'HTMLPurifier/ChildDef/Empty.php';
|
||||
require_once 'HTMLPurifier/ChildDef/Required.php';
|
||||
require_once 'HTMLPurifier/ChildDef/Optional.php';
|
||||
|
||||
// NOT UNIT TESTED!!!
|
||||
|
||||
class HTMLPurifier_ContentSets
|
||||
{
|
||||
|
||||
|
@ -24,8 +24,8 @@ class HTMLPurifier_EntityParser
|
||||
* @protected
|
||||
*/
|
||||
var $_substituteEntitiesRegex =
|
||||
'/&(?:[#]x([a-fA-F0-9]+)|[#]0*(\d+)|([A-Za-z]+));?/';
|
||||
// 1. hex 2. dec 3. string
|
||||
'/&(?:[#]x([a-fA-F0-9]+)|[#]0*(\d+)|([A-Za-z_:][A-Za-z0-9.\-_:]*));?/';
|
||||
// 1. hex 2. dec 3. string (XML style)
|
||||
|
||||
|
||||
/**
|
||||
@ -97,7 +97,6 @@ class HTMLPurifier_EntityParser
|
||||
} else {
|
||||
if (isset($this->_special_ent2dec[$matches[3]])) return $entity;
|
||||
if (!$this->_entity_lookup) {
|
||||
require_once 'HTMLPurifier/EntityLookup.php';
|
||||
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
||||
}
|
||||
if (isset($this->_entity_lookup->table[$matches[3]])) {
|
||||
|
@ -97,27 +97,6 @@ class HTMLPurifier_HTMLModule
|
||||
*/
|
||||
function getChildDef($def) {return false;}
|
||||
|
||||
/**
|
||||
* Hook method that lets module perform arbitrary operations on
|
||||
* HTMLPurifier_HTMLDefinition before the module gets processed.
|
||||
* @param $definition Reference to HTMLDefinition being setup
|
||||
*/
|
||||
function preProcess(&$definition) {}
|
||||
|
||||
/**
|
||||
* Hook method that lets module perform arbitrary operations
|
||||
* on HTMLPurifier_HTMLDefinition after the module gets processed.
|
||||
* @param $definition Reference to HTMLDefinition being setup
|
||||
*/
|
||||
function postProcess(&$definition) {}
|
||||
|
||||
/**
|
||||
* Hook method that is called when a module gets registered to
|
||||
* the definition.
|
||||
* @param $definition Reference to HTMLDefinition being setup
|
||||
*/
|
||||
function setup(&$definition) {}
|
||||
|
||||
// -- Convenience -----------------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
require_once 'HTMLPurifier/LanguageFactory.php';
|
||||
|
||||
// UNUSED
|
||||
|
||||
class HTMLPurifier_Language
|
||||
{
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
require_once 'HTMLPurifier/Language.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Lang.php';
|
||||
|
||||
// UNUSED
|
||||
|
||||
/**
|
||||
* Class responsible for generating HTMLPurifier_Language objects, managing
|
||||
* caching and fallbacks.
|
||||
|
@ -4,6 +4,8 @@ require_once 'HTMLPurifier/Generator.php';
|
||||
require_once 'HTMLPurifier/Token.php';
|
||||
require_once 'HTMLPurifier/Encoder.php';
|
||||
|
||||
// OUT OF DATE, NEEDS UPDATING!
|
||||
|
||||
class HTMLPurifier_Printer
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user