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',
'Iframe');
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(
117 array_merge($common, $xml, array(
'Ruby',
'Iframe')),
118 array(
'Tidy_Strict',
'Tidy_XHTML',
'Tidy_Proprietary',
'Tidy_Strict',
'Tidy_Name'),
120 '-//W3C//DTD XHTML 1.1//EN',
121 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
148 if (is_string($module)) {
150 $original_module = $module;
152 foreach ($this->prefixes as $prefix) {
153 $module = $prefix . $original_module;
154 if (class_exists($module)) {
160 $module = $original_module;
161 if (!class_exists($module)) {
162 trigger_error($original_module .
' module does not exist',
167 $module =
new $module();
169 if (empty($module->name)) {
170 trigger_error(
'Module instance of ' . get_class($module) .
' must have name');
173 if (!$overload && isset($this->registeredModules[$module->name])) {
174 trigger_error(
'Overloading ' . $module->name .
' without explicit overload parameter', E_USER_WARNING);
176 $this->registeredModules[$module->name] = $module;
185 if (is_object($module)) $module = $module->name;
186 $this->userModules[] = $module;
194 $this->prefixes[] = $prefix;
204 $this->trusted = $config->get(
'HTML.Trusted');
207 $this->doctype = $this->doctypes->make($config);
211 $lookup = $config->get(
'HTML.AllowedModules');
212 $special_cases = $config->get(
'HTML.CoreModules');
214 if (is_array($lookup)) {
216 if (isset($special_cases[$m]))
continue;
217 if (!isset($lookup[$m])) unset(
$modules[$k]);
222 if ($config->get(
'HTML.Proprietary')) {
225 if ($config->get(
'HTML.SafeObject')) {
228 if ($config->get(
'HTML.SafeEmbed')) {
231 if ($config->get(
'HTML.SafeScripting') !== array()) {
234 if ($config->get(
'HTML.Nofollow')) {
237 if ($config->get(
'HTML.TargetBlank')) {
246 $this->modules[$module]->setup($config);
249 foreach ($this->doctype->tidyModules as $module) {
251 $this->modules[$module]->setup($config);
255 foreach ($this->modules as $module) {
257 foreach ($module->info_injector as $i => $injector) {
258 if (!is_object($injector)) {
259 $class =
"HTMLPurifier_Injector_$injector";
260 $injector =
new $class;
262 $n[$injector->name] = $injector;
264 $module->info_injector =
$n;
268 foreach ($this->modules as $module) {
269 foreach ($module->info as $name => $def) {
270 if (!isset($this->elementLookup[$name])) {
271 $this->elementLookup[$name] = array();
273 $this->elementLookup[$name][] = $module->name;
297 if (!isset($this->registeredModules[$module]) || is_object($module)) {
300 $this->modules[$module] = $this->registeredModules[$module];
310 foreach ($this->modules as $module) {
311 if (!$this->trusted && !$module->safe)
continue;
312 foreach ($module->info as $name => $v) {
313 if (isset($elements[$name]))
continue;
320 foreach ($elements as
$n => $v) {
321 if ($v ===
false) unset($elements[
$n]);
340 if (!isset($this->elementLookup[$name])) {
350 foreach($this->elementLookup[$name] as $module_name) {
352 $module = $this->modules[$module_name];
363 $new_def = clone $module->info[$name];
365 if (!$def && $new_def->standalone) {
370 $def->mergeIn($new_def);
386 $this->attrCollections->performInclusions($def->attr);
387 $this->attrCollections->expandIdentifiers($def->attr, $this->attrTypes);
390 if (is_string($def->content_model) &&
391 strpos($def->content_model,
'Inline') !==
false) {
392 if ($name !=
'del' && $name !=
'ins') {
394 $def->descendants_are_inline =
true;
398 $this->contentSets->generateChildDef($def, $module);
403 if (!$def)
return false;
406 foreach ($def->attr as $attr_name => $attr_def) {
407 if ($attr_def->required) {
408 $def->required_attr[] = $attr_name;