56 public $prefixes = array(
'HTMLPurifier_HTMLModule_');
82 'CommonAttributes',
'Text',
'Hypertext',
'List',
83 'Presentation',
'Edit',
'Bdo',
'Tables',
'Image',
86 'Scripting',
'Object',
'Forms',
90 $transitional = array(
'Legacy',
'Target',
'Iframe');
91 $xml = array(
'XMLCommonAttributes');
92 $non_xml = array(
'NonXMLCommonAttributes');
95 $this->doctypes->register(
96 'HTML 4.01 Transitional',
98 array_merge($common, $transitional, $non_xml),
99 array(
'Tidy_Transitional',
'Tidy_Proprietary'),
101 '-//W3C//DTD HTML 4.01 Transitional//EN',
102 'http://www.w3.org/TR/html4/loose.dtd'
105 $this->doctypes->register(
108 array_merge($common, $non_xml),
109 array(
'Tidy_Strict',
'Tidy_Proprietary',
'Tidy_Name'),
111 '-//W3C//DTD HTML 4.01//EN',
112 'http://www.w3.org/TR/html4/strict.dtd'
115 $this->doctypes->register(
116 'XHTML 1.0 Transitional',
118 array_merge($common, $transitional, $xml, $non_xml),
119 array(
'Tidy_Transitional',
'Tidy_XHTML',
'Tidy_Proprietary',
'Tidy_Name'),
121 '-//W3C//DTD XHTML 1.0 Transitional//EN',
122 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'
125 $this->doctypes->register(
128 array_merge($common, $xml, $non_xml),
129 array(
'Tidy_Strict',
'Tidy_XHTML',
'Tidy_Strict',
'Tidy_Proprietary',
'Tidy_Name'),
131 '-//W3C//DTD XHTML 1.0 Strict//EN',
132 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
135 $this->doctypes->register(
140 array_merge($common, $xml, array(
'Ruby',
'Iframe')),
141 array(
'Tidy_Strict',
'Tidy_XHTML',
'Tidy_Proprietary',
'Tidy_Strict',
'Tidy_Name'),
143 '-//W3C//DTD XHTML 1.1//EN',
144 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
172 if (is_string($module)) {
174 $original_module = $module;
176 foreach ($this->prefixes as $prefix) {
177 $module = $prefix . $original_module;
178 if (class_exists($module)) {
184 $module = $original_module;
185 if (!class_exists($module)) {
187 $original_module .
' module does not exist',
193 $module =
new $module();
195 if (empty($module->name)) {
196 trigger_error(
'Module instance of ' . get_class($module) .
' must have name');
199 if (!$overload && isset($this->registeredModules[$module->name])) {
200 trigger_error(
'Overloading ' . $module->name .
' without explicit overload parameter', E_USER_WARNING);
202 $this->registeredModules[$module->name] = $module;
212 if (is_object($module)) {
213 $module = $module->name;
215 $this->userModules[] = $module;
224 $this->prefixes[] = $prefix;
234 $this->trusted = $config->get(
'HTML.Trusted');
237 $this->doctype = $this->doctypes->make($config);
241 $lookup = $config->get(
'HTML.AllowedModules');
242 $special_cases = $config->get(
'HTML.CoreModules');
244 if (is_array($lookup)) {
246 if (isset($special_cases[$m])) {
249 if (!isset($lookup[$m])) {
256 if ($config->get(
'HTML.Proprietary')) {
259 if ($config->get(
'HTML.SafeObject')) {
262 if ($config->get(
'HTML.SafeEmbed')) {
265 if ($config->get(
'HTML.SafeScripting') !== array()) {
268 if ($config->get(
'HTML.Nofollow')) {
271 if ($config->get(
'HTML.TargetBlank')) {
280 $this->modules[$module]->setup($config);
283 foreach ($this->doctype->tidyModules as $module) {
285 $this->modules[$module]->setup($config);
289 foreach ($this->modules as $module) {
291 foreach ($module->info_injector as $injector) {
292 if (!is_object($injector)) {
293 $class =
"HTMLPurifier_Injector_$injector";
294 $injector =
new $class;
296 $n[$injector->name] = $injector;
298 $module->info_injector =
$n;
302 foreach ($this->modules as $module) {
303 foreach ($module->info as $name => $def) {
304 if (!isset($this->elementLookup[$name])) {
305 $this->elementLookup[$name] = array();
307 $this->elementLookup[$name][] = $module->name;
332 if (!isset($this->registeredModules[$module]) || is_object($module)) {
335 $this->modules[$module] = $this->registeredModules[$module];
345 foreach ($this->modules as $module) {
346 if (!$this->trusted && !$module->safe) {
349 foreach ($module->info as $name => $v) {
350 if (isset($elements[$name])) {
359 foreach ($elements as
$n => $v) {
361 unset($elements[
$n]);
381 if (!isset($this->elementLookup[$name])) {
393 foreach ($this->elementLookup[$name] as $module_name) {
394 $module = $this->modules[$module_name];
405 $new_def = clone $module->info[$name];
407 if (!$def && $new_def->standalone) {
412 $def->mergeIn($new_def);
428 $this->attrCollections->performInclusions($def->attr);
429 $this->attrCollections->expandIdentifiers($def->attr, $this->attrTypes);
432 if (is_string($def->content_model) &&
433 strpos($def->content_model,
'Inline') !==
false) {
434 if ($name !=
'del' && $name !=
'ins') {
436 $def->descendants_are_inline =
true;
440 $this->contentSets->generateChildDef($def, $module);
450 foreach ($def->attr as $attr_name => $attr_def) {
451 if ($attr_def->required) {
452 $def->required_attr[] = $attr_name;