mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-20 12:31:53 +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
|
* Lookup array of attribute string identifiers to concrete implementations
|
||||||
* @public
|
* @protected
|
||||||
*/
|
*/
|
||||||
var $info = array();
|
var $info = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs the info array
|
* Constructs the info array, supplying default implementations for attribute
|
||||||
|
* types.
|
||||||
*/
|
*/
|
||||||
function HTMLPurifier_AttrTypes() {
|
function HTMLPurifier_AttrTypes() {
|
||||||
$this->info['CDATA'] = new HTMLPurifier_AttrDef_Text();
|
$this->info['CDATA'] = new HTMLPurifier_AttrDef_Text();
|
||||||
@ -40,15 +41,27 @@ class HTMLPurifier_AttrTypes
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a type
|
* Retrieves a type
|
||||||
|
* @param $type String type name
|
||||||
|
* @return Object AttrDef for type
|
||||||
*/
|
*/
|
||||||
function get($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])) {
|
if (!isset($this->info[$type])) {
|
||||||
trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
|
trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return $this->info[$type];
|
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/Required.php';
|
||||||
require_once 'HTMLPurifier/ChildDef/Optional.php';
|
require_once 'HTMLPurifier/ChildDef/Optional.php';
|
||||||
|
|
||||||
|
// NOT UNIT TESTED!!!
|
||||||
|
|
||||||
class HTMLPurifier_ContentSets
|
class HTMLPurifier_ContentSets
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ class HTMLPurifier_EntityParser
|
|||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
var $_substituteEntitiesRegex =
|
var $_substituteEntitiesRegex =
|
||||||
'/&(?:[#]x([a-fA-F0-9]+)|[#]0*(\d+)|([A-Za-z]+));?/';
|
'/&(?:[#]x([a-fA-F0-9]+)|[#]0*(\d+)|([A-Za-z_:][A-Za-z0-9.\-_:]*));?/';
|
||||||
// 1. hex 2. dec 3. string
|
// 1. hex 2. dec 3. string (XML style)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,7 +97,6 @@ class HTMLPurifier_EntityParser
|
|||||||
} else {
|
} else {
|
||||||
if (isset($this->_special_ent2dec[$matches[3]])) return $entity;
|
if (isset($this->_special_ent2dec[$matches[3]])) return $entity;
|
||||||
if (!$this->_entity_lookup) {
|
if (!$this->_entity_lookup) {
|
||||||
require_once 'HTMLPurifier/EntityLookup.php';
|
|
||||||
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
$this->_entity_lookup = HTMLPurifier_EntityLookup::instance();
|
||||||
}
|
}
|
||||||
if (isset($this->_entity_lookup->table[$matches[3]])) {
|
if (isset($this->_entity_lookup->table[$matches[3]])) {
|
||||||
|
@ -97,27 +97,6 @@ class HTMLPurifier_HTMLModule
|
|||||||
*/
|
*/
|
||||||
function getChildDef($def) {return false;}
|
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 -----------------------------------------------------
|
// -- Convenience -----------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
require_once 'HTMLPurifier/LanguageFactory.php';
|
require_once 'HTMLPurifier/LanguageFactory.php';
|
||||||
|
|
||||||
|
// UNUSED
|
||||||
|
|
||||||
class HTMLPurifier_Language
|
class HTMLPurifier_Language
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
require_once 'HTMLPurifier/Language.php';
|
require_once 'HTMLPurifier/Language.php';
|
||||||
require_once 'HTMLPurifier/AttrDef/Lang.php';
|
require_once 'HTMLPurifier/AttrDef/Lang.php';
|
||||||
|
|
||||||
|
// UNUSED
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class responsible for generating HTMLPurifier_Language objects, managing
|
* Class responsible for generating HTMLPurifier_Language objects, managing
|
||||||
* caching and fallbacks.
|
* caching and fallbacks.
|
||||||
|
@ -4,6 +4,8 @@ require_once 'HTMLPurifier/Generator.php';
|
|||||||
require_once 'HTMLPurifier/Token.php';
|
require_once 'HTMLPurifier/Token.php';
|
||||||
require_once 'HTMLPurifier/Encoder.php';
|
require_once 'HTMLPurifier/Encoder.php';
|
||||||
|
|
||||||
|
// OUT OF DATE, NEEDS UPDATING!
|
||||||
|
|
||||||
class HTMLPurifier_Printer
|
class HTMLPurifier_Printer
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user