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.Nofollow')) {
234 if ($config->get(
'HTML.TargetBlank')) {
243 $this->modules[$module]->setup($config);
246 foreach ($this->doctype->tidyModules as $module) {
248 $this->modules[$module]->setup($config);
252 foreach ($this->modules as $module) {
254 foreach ($module->info_injector as $i => $injector) {
255 if (!is_object($injector)) {
256 $class =
"HTMLPurifier_Injector_$injector";
257 $injector =
new $class;
259 $n[$injector->name] = $injector;
261 $module->info_injector =
$n;
265 foreach ($this->modules as $module) {
266 foreach ($module->info as $name => $def) {
267 if (!isset($this->elementLookup[$name])) {
268 $this->elementLookup[$name] = array();
270 $this->elementLookup[$name][] = $module->name;
294 if (!isset($this->registeredModules[$module]) || is_object($module)) {
297 $this->modules[$module] = $this->registeredModules[$module];
307 foreach ($this->modules as $module) {
308 if (!$this->trusted && !$module->safe)
continue;
309 foreach ($module->info as $name => $v) {
310 if (isset($elements[$name]))
continue;
317 foreach ($elements as
$n => $v) {
318 if ($v ===
false) unset($elements[
$n]);
337 if (!isset($this->elementLookup[$name])) {
347 foreach($this->elementLookup[$name] as $module_name) {
349 $module = $this->modules[$module_name];
360 $new_def = clone $module->info[$name];
362 if (!$def && $new_def->standalone) {
367 $def->mergeIn($new_def);
383 $this->attrCollections->performInclusions($def->attr);
384 $this->attrCollections->expandIdentifiers($def->attr, $this->attrTypes);
387 if (is_string($def->content_model) &&
388 strpos($def->content_model,
'Inline') !==
false) {
389 if ($name !=
'del' && $name !=
'ins') {
391 $def->descendants_are_inline =
true;
395 $this->contentSets->generateChildDef($def, $module);
400 if (!$def)
return false;
403 foreach ($def->attr as $attr_name => $attr_def) {
404 if ($attr_def->required) {
405 $def->required_attr[] = $attr_name;