1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-02 04:10:25 +02:00

Enforce info_ prefix convention for data that is accessed by HTML Purifier internals.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@720 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-02-04 22:08:51 +00:00
parent 9d8f839bf2
commit 236159242f
3 changed files with 27 additions and 24 deletions

View File

@@ -19,7 +19,7 @@ extends HTMLPurifier_ChildDef_Required
if (!$this->init) { if (!$this->init) {
// allow all inline elements // allow all inline elements
$this->real_elements = $this->elements; $this->real_elements = $this->elements;
$this->fake_elements = $def->content_sets['Flow']; $this->fake_elements = $def->info_content_sets['Flow'];
$this->fake_elements['#PCDATA'] = true; $this->fake_elements['#PCDATA'] = true;
$this->init = true; $this->init = true;
} }

View File

@@ -99,20 +99,25 @@ HTMLPurifier_ConfigSchema::define(
); );
/** /**
* Defines the purified HTML type with large amounts of objects. * Definition of the purified HTML that describes allowed children,
* attributes, and many other things.
* *
* The main function of this object is its $info array, which is an * Conventions:
* associative array of all the child and attribute definitions for
* each allowed element. It also contains special use information (always
* prefixed by info) for intelligent tag closing and global attributes.
* *
* For optimization, the definition generation may be moved to * All member variables that are prefixed with info
* a maintenance script and stipulate that definition be created * (including the main $info array) are used by HTML Purifier internals
* by a factory method that unserializes a serialized version of Definition. * and should not be directly edited when customizing the HTMLDefinition.
* Customization would entail copying the maintenance script, making the * They can usually be set via configuration directives or custom
* necessary changes, generating the serialized object, and then hooking it * modules.
* in via the factory method. We would also offer a LiveDefinition for *
* automatic recompilation, suggesting that we would have a DefinitionGenerator. * On the other hand, member variables without the info prefix are used
* internally by the HTMLDefinition and MUST NOT be used by other HTML
* Purifier internals. Many of them, however, are public, and may be
* edited by userspace code to tweak the behavior of HTMLDefinition.
* In practice, there will not be too many of them.
*
* HTMLPurifier_Printer_HTMLDefinition is a notable exception to this
* rule: in the interest of comprehensiveness, it will sniff everything.
*/ */
class HTMLPurifier_HTMLDefinition class HTMLPurifier_HTMLDefinition
@@ -168,14 +173,19 @@ class HTMLPurifier_HTMLDefinition
*/ */
var $info_attr_transform_post = array(); var $info_attr_transform_post = array();
/**
* Nested lookup array of content set name (Block, Inline) to
* element name to whether or not it belongs in that content set.
* @public
*/
var $info_content_sets = array();
/** /**
* Boolean is a strict definition? * Boolean is a strict definition?
* @public * @public
*/ */
var $strict; var $strict;
var $content_sets = array();
/** /**
* Initializes the definition, the meat of the class. * Initializes the definition, the meat of the class.
*/ */
@@ -355,7 +365,7 @@ class HTMLPurifier_HTMLDefinition
} }
foreach ($e_Flow->elements as $name => $bool) { foreach ($e_Flow->elements as $name => $bool) {
$this->content_sets['Flow'][$name] = true; $this->info_content_sets['Flow'][$name] = true;
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////

View File

@@ -53,13 +53,6 @@ class HTMLPurifier_XHTMLDefinition extends HTMLPurifier_HTMLDefinition
*/ */
var $attr_collection; var $attr_collection;
/**
* Nested lookup array of content set name (Block, Inline) to
* element name to whether or not it belongs in that content set.
* @public
*/
var $content_sets;
/** /**
* Performs low-cost, preliminary initialization. * Performs low-cost, preliminary initialization.
* @param $config Instance of HTMLPurifier_Config * @param $config Instance of HTMLPurifier_Config
@@ -120,7 +113,7 @@ class HTMLPurifier_XHTMLDefinition extends HTMLPurifier_HTMLDefinition
$content_sets_keys = array_keys($content_sets); $content_sets_keys = array_keys($content_sets);
$content_sets_values = array_values($content_sets); $content_sets_values = array_values($content_sets);
foreach ($content_sets as $name => $set) { foreach ($content_sets as $name => $set) {
$this->content_sets[$name] = $this->convertToLookup($set); $this->info_content_sets[$name] = $this->convertToLookup($set);
} }
foreach ($this->modules as $module_i => $module) { foreach ($this->modules as $module_i => $module) {