diff --git a/library/HTMLPurifier/AttrCollections.php b/library/HTMLPurifier/AttrCollections.php index c731a176..8318abb1 100644 --- a/library/HTMLPurifier/AttrCollections.php +++ b/library/HTMLPurifier/AttrCollections.php @@ -15,32 +15,7 @@ class HTMLPurifier_AttrCollections * @note Technically, the composition of these is more complicated, * but we bypass it using our own excludes property */ - var $info = array( - 'Core' => array( - 0 => array('Style'), - // 'xml:space' => false, - 'class' => 'NMTOKENS', - 'id' => 'ID', - 'title' => 'CDATA', - ), - 'Lang' => array( - 'xml:lang' => false, // see constructor - ), - 'I18N' => array( - 0 => array('Lang'), // proprietary, for xml:lang/lang - ), - 'Common' => array( - 0 => array('Core', 'I18N') - ) - ); - - /** - * Sets up direct objects not registered to HTMLPurifier_AttrTypes - */ - function HTMLPurifier_AttrCollections() { - // setup direct objects - $this->info['Lang']['xml:lang'] = new HTMLPurifier_AttrDef_Lang(); - } + var $info = array(); /** * Performs all expansions on internal data for use by other inclusions @@ -49,7 +24,7 @@ class HTMLPurifier_AttrCollections * @param $attr_types HTMLPurifier_AttrTypes instance * @param $modules Hash array of HTMLPurifier_HTMLModule members */ - function setup($attr_types, $modules) { + function HTMLPurifier_AttrCollections($attr_types, $modules) { $info =& $this->info; // load extensions from the modules foreach ($modules as $module) { diff --git a/library/HTMLPurifier/HTMLModule/CommonAttributes.php b/library/HTMLPurifier/HTMLModule/CommonAttributes.php new file mode 100644 index 00000000..c8ba2fe2 --- /dev/null +++ b/library/HTMLPurifier/HTMLModule/CommonAttributes.php @@ -0,0 +1,32 @@ + array( + 0 => array('Style'), + // 'xml:space' => false, + 'class' => 'NMTOKENS', + 'id' => 'ID', + 'title' => 'CDATA', + ), + 'Lang' => array( + 'xml:lang' => false, // see constructor + ), + 'I18N' => array( + 0 => array('Lang'), // proprietary, for xml:lang/lang + ), + 'Common' => array( + 0 => array('Core', 'I18N') + ) + ); + + function HTMLPurifier_HTMLModule_CommonAttributes() { + $this->attr_collections['Lang']['xml:lang'] = new HTMLPurifier_AttrDef_Lang(); + } +} + +?> \ No newline at end of file diff --git a/library/HTMLPurifier/HTMLModuleManager.php b/library/HTMLPurifier/HTMLModuleManager.php index cf9a9215..68f93763 100644 --- a/library/HTMLPurifier/HTMLModuleManager.php +++ b/library/HTMLPurifier/HTMLModuleManager.php @@ -4,6 +4,7 @@ require_once 'HTMLPurifier/ContentSets.php'; require_once 'HTMLPurifier/HTMLModule.php'; // W3C modules +require_once 'HTMLPurifier/HTMLModule/CommonAttributes.php'; require_once 'HTMLPurifier/HTMLModule/Text.php'; require_once 'HTMLPurifier/HTMLModule/Hypertext.php'; require_once 'HTMLPurifier/HTMLModule/List.php'; @@ -41,6 +42,7 @@ class HTMLPurifier_HTMLModuleManager */ var $collectionsSafe = array( '_Common' => array( // leading _ indicates private + 'CommonAttributes', 'Text', 'Hypertext', 'List', @@ -103,6 +105,7 @@ class HTMLPurifier_HTMLModuleManager // modules $modules = array( // define + 'CommonAttributes', 'Text', 'Hypertext', 'List', 'Presentation', 'Edit', 'Bdo', 'Tables', 'Image', 'StyleAttribute', // define-redefine @@ -115,8 +118,9 @@ class HTMLPurifier_HTMLModuleManager $this->addModule($module); } - $this->attrTypes = new HTMLPurifier_AttrTypes(); - $this->attrCollections = new HTMLPurifier_AttrCollections(); + // the only editable internal object. The rest need to + // be manipulated through modules + $this->attrTypes = new HTMLPurifier_AttrTypes(); } @@ -200,7 +204,7 @@ class HTMLPurifier_HTMLModuleManager $this->contentSets = new HTMLPurifier_ContentSets( $this->getModules($config, true) ); - $this->attrCollections->setup($this->attrTypes, + $this->attrCollections = new HTMLPurifier_AttrCollections($this->attrTypes, $this->getModules($config)); }