mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 23:28:42 +00: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:
parent
9d8f839bf2
commit
236159242f
@ -19,7 +19,7 @@ extends HTMLPurifier_ChildDef_Required
|
||||
if (!$this->init) {
|
||||
// allow all inline 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->init = true;
|
||||
}
|
||||
|
@ -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
|
||||
* 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.
|
||||
* Conventions:
|
||||
*
|
||||
* For optimization, the definition generation may be moved to
|
||||
* a maintenance script and stipulate that definition be created
|
||||
* by a factory method that unserializes a serialized version of Definition.
|
||||
* Customization would entail copying the maintenance script, making the
|
||||
* necessary changes, generating the serialized object, and then hooking it
|
||||
* in via the factory method. We would also offer a LiveDefinition for
|
||||
* automatic recompilation, suggesting that we would have a DefinitionGenerator.
|
||||
* All member variables that are prefixed with info
|
||||
* (including the main $info array) are used by HTML Purifier internals
|
||||
* and should not be directly edited when customizing the HTMLDefinition.
|
||||
* They can usually be set via configuration directives or custom
|
||||
* modules.
|
||||
*
|
||||
* 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
|
||||
@ -168,14 +173,19 @@ class HTMLPurifier_HTMLDefinition
|
||||
*/
|
||||
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?
|
||||
* @public
|
||||
*/
|
||||
var $strict;
|
||||
|
||||
var $content_sets = array();
|
||||
|
||||
/**
|
||||
* Initializes the definition, the meat of the class.
|
||||
*/
|
||||
@ -355,7 +365,7 @@ class HTMLPurifier_HTMLDefinition
|
||||
}
|
||||
|
||||
foreach ($e_Flow->elements as $name => $bool) {
|
||||
$this->content_sets['Flow'][$name] = true;
|
||||
$this->info_content_sets['Flow'][$name] = true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -53,13 +53,6 @@ class HTMLPurifier_XHTMLDefinition extends HTMLPurifier_HTMLDefinition
|
||||
*/
|
||||
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.
|
||||
* @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_values = array_values($content_sets);
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user