48 public $prefixes = array(
'HTMLPurifier_HTMLModule_');
64 'CommonAttributes',
'Text',
'Hypertext',
'List',
65 'Presentation',
'Edit',
'Bdo',
'Tables',
'Image',
68 'Scripting',
'Object',
'Forms',
72 $transitional = array(
'Legacy',
'Target');
73 $xml = array(
'XMLCommonAttributes');
74 $non_xml = array(
'NonXMLCommonAttributes');
77 $this->doctypes->register(
78 'HTML 4.01 Transitional',
false,
79 array_merge($common, $transitional, $non_xml),
80 array(
'Tidy_Transitional',
'Tidy_Proprietary'),
82 '-//W3C//DTD HTML 4.01 Transitional//EN',
83 'http://www.w3.org/TR/html4/loose.dtd'
86 $this->doctypes->register(
87 'HTML 4.01 Strict',
false,
88 array_merge($common, $non_xml),
89 array(
'Tidy_Strict',
'Tidy_Proprietary',
'Tidy_Name'),
91 '-//W3C//DTD HTML 4.01//EN',
92 'http://www.w3.org/TR/html4/strict.dtd'
95 $this->doctypes->register(
96 'XHTML 1.0 Transitional',
true,
97 array_merge($common, $transitional, $xml, $non_xml),
98 array(
'Tidy_Transitional',
'Tidy_XHTML',
'Tidy_Proprietary',
'Tidy_Name'),
100 '-//W3C//DTD XHTML 1.0 Transitional//EN',
101 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'
104 $this->doctypes->register(
105 'XHTML 1.0 Strict',
true,
106 array_merge($common, $xml, $non_xml),
107 array(
'Tidy_Strict',
'Tidy_XHTML',
'Tidy_Strict',
'Tidy_Proprietary',
'Tidy_Name'),
109 '-//W3C//DTD XHTML 1.0 Strict//EN',
110 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
113 $this->doctypes->register(
115 array_merge($common, $xml, array(
'Ruby')),
116 array(
'Tidy_Strict',
'Tidy_XHTML',
'Tidy_Proprietary',
'Tidy_Strict',
'Tidy_Name'),
118 '-//W3C//DTD XHTML 1.1//EN',
119 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
146 if (is_string($module)) {
148 $original_module = $module;
150 foreach ($this->prefixes as $prefix) {
151 $module = $prefix . $original_module;
152 if (class_exists($module)) {
158 $module = $original_module;
159 if (!class_exists($module)) {
160 trigger_error($original_module .
' module does not exist',
165 $module =
new $module();
167 if (empty($module->name)) {
168 trigger_error(
'Module instance of ' . get_class($module) .
' must have name');
171 if (!$overload && isset($this->registeredModules[$module->name])) {
172 trigger_error(
'Overloading ' . $module->name .
' without explicit overload parameter', E_USER_WARNING);
174 $this->registeredModules[$module->name] = $module;
183 if (is_object($module)) $module = $module->name;
184 $this->userModules[] = $module;
192 $this->prefixes[] = $prefix;
202 $this->trusted =
$config->get(
'HTML.Trusted');
205 $this->doctype = $this->doctypes->make(
$config);
209 $lookup =
$config->get(
'HTML.AllowedModules');
210 $special_cases =
$config->get(
'HTML.CoreModules');
212 if (is_array($lookup)) {
214 if (isset($special_cases[$m]))
continue;
215 if (!isset($lookup[$m])) unset(
$modules[$k]);
220 if (
$config->get(
'HTML.Proprietary')) {
223 if (
$config->get(
'HTML.SafeObject')) {
226 if (
$config->get(
'HTML.SafeEmbed')) {
229 if (
$config->get(
'HTML.Nofollow')) {
238 $this->modules[$module]->setup(
$config);
241 foreach ($this->doctype->tidyModules as $module) {
243 $this->modules[$module]->setup(
$config);
247 foreach ($this->modules as $module) {
249 foreach ($module->info_injector as $i => $injector) {
250 if (!is_object($injector)) {
251 $class =
"HTMLPurifier_Injector_$injector";
252 $injector =
new $class;
254 $n[$injector->name] = $injector;
256 $module->info_injector =
$n;
260 foreach ($this->modules as $module) {
261 foreach ($module->info as $name => $def) {
262 if (!isset($this->elementLookup[$name])) {
263 $this->elementLookup[$name] = array();
265 $this->elementLookup[$name][] = $module->name;
289 if (!isset($this->registeredModules[$module]) || is_object($module)) {
292 $this->modules[$module] = $this->registeredModules[$module];
302 foreach ($this->modules as $module) {
303 if (!$this->trusted && !$module->safe)
continue;
304 foreach ($module->info as $name => $v) {
305 if (isset($elements[$name]))
continue;
312 foreach ($elements as
$n => $v) {
313 if ($v ===
false) unset($elements[
$n]);
332 if (!isset($this->elementLookup[$name])) {
342 foreach($this->elementLookup[$name] as $module_name) {
344 $module = $this->modules[$module_name];
355 $new_def = clone $module->info[$name];
357 if (!$def && $new_def->standalone) {
362 $def->mergeIn($new_def);
371 $this->attrCollections->performInclusions($def->attr);
372 $this->attrCollections->expandIdentifiers($def->attr, $this->attrTypes);
375 if (is_string($def->content_model) &&
376 strpos($def->content_model,
'Inline') !==
false) {
377 if ($name !=
'del' && $name !=
'ins') {
379 $def->descendants_are_inline =
true;
383 $this->contentSets->generateChildDef($def, $module);
388 if (!$def)
return false;
391 foreach ($def->attr as $attr_name => $attr_def) {
392 if ($attr_def->required) {
393 $def->required_attr[] = $attr_name;