diff --git a/library/HTMLPurifier/Definition.php b/library/HTMLPurifier/Definition.php
index 2ece6ac1..ffc3ae78 100644
--- a/library/HTMLPurifier/Definition.php
+++ b/library/HTMLPurifier/Definition.php
@@ -7,11 +7,33 @@ require_once 'HTMLPurifier/ChildDef.php';
require_once 'HTMLPurifier/Generator.php';
require_once 'HTMLPurifier/Token.php';
+/**
+ * Defines the purified HTML type with large amounts of objects.
+ *
+ * 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.
+ *
+ * Planned improvements include attribute transformation objects as well as
+ * migration of auto-tag-closing from HTMLPurifier_Strategy_MakeWellFormed
+ * (these can likely just be extensions of ElementDef).
+ *
+ * After development drops off, the definition generation will be moved to
+ * a maintenance script and we will 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.
+ */
+
class HTMLPurifier_Definition
{
- var $generator;
var $info = array();
+
+ // used solely by HTMLPurifier_Strategy_MakeWellFormed
var $info_closes_p = array(
// these are all block elements: blocks aren't allowed in P
'address' => true,
@@ -34,8 +56,13 @@ class HTMLPurifier_Definition
'table' => true,
'ul' => true
);
+
+ // used solely by HTMLPurifier_Strategy_ValidateAttributes
var $info_global_attr = array();
+ // used solely by HTMLPurifier_Strategy_FixNesting
+ var $info_parent = 'div';
+
function instance() {
static $instance = null;
if (!$instance) {
diff --git a/library/HTMLPurifier/Strategy/FixNesting.php b/library/HTMLPurifier/Strategy/FixNesting.php
index 1bca623c..35e78e16 100644
--- a/library/HTMLPurifier/Strategy/FixNesting.php
+++ b/library/HTMLPurifier/Strategy/FixNesting.php
@@ -14,8 +14,10 @@ class HTMLPurifier_Strategy_FixNesting extends HTMLPurifier_Strategy
function execute($tokens) {
// insert implicit "parent" node, will be removed at end
- array_unshift($tokens, new HTMLPurifier_Token_Start('div'));
- $tokens[] = new HTMLPurifier_Token_End('div');
+ $parent_name = $this->definition->info_parent;
+
+ array_unshift($tokens, new HTMLPurifier_Token_Start($parent_name));
+ $tokens[] = new HTMLPurifier_Token_End($parent_name);
for ($i = 0, $size = count($tokens) ; $i < $size; ) {
diff --git a/library/HTMLPurifier/Strategy/MakeWellFormed.php b/library/HTMLPurifier/Strategy/MakeWellFormed.php
index 397e6916..6f982df0 100644
--- a/library/HTMLPurifier/Strategy/MakeWellFormed.php
+++ b/library/HTMLPurifier/Strategy/MakeWellFormed.php
@@ -61,6 +61,8 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
if (!empty($current_nesting)) {
$current_parent = array_pop($current_nesting);
+ // this ought to be moved to definition
+
// check if we're closing a P tag
if ($current_parent->name == 'p' &&
isset($this->definition->info_closes_p[$token->name])