82 'CommonAttributes',
'Text',
'Hypertext',
'List',
83 'Presentation',
'Edit',
'Bdo',
'Tables',
'Image',
86 'Scripting',
'Object',
'Forms',
90 $transitional =
array(
'Legacy',
'Target',
'Iframe');
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' 176 foreach ($this->prefixes as $prefix) {
177 $module = $prefix . $original_module;
187 $original_module .
' module does not exist',
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);
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')) {
268 if (
$config->get(
'HTML.Nofollow')) {
271 if (
$config->get(
'HTML.TargetBlank')) {
276 if (
$config->get(
'HTML.TargetNoreferrer')) {
279 if (
$config->get(
'HTML.TargetNoopener')) {
291 foreach ($this->doctype->tidyModules as $module) {
297 foreach ($this->modules as $module) {
299 foreach ($module->info_injector as $injector) {
300 if (!is_object($injector)) {
301 $class =
"HTMLPurifier_Injector_$injector";
302 $injector =
new $class;
304 $n[$injector->name] = $injector;
306 $module->info_injector =
$n;
310 foreach ($this->modules as $module) {
311 foreach ($module->info as
$name =>
$def) {
312 if (!isset($this->elementLookup[
$name])) {
315 $this->elementLookup[
$name][] = $module->name;
340 if (!isset($this->registeredModules[
$module]) || is_object($module)) {
353 foreach ($this->modules as
$module) {
354 if (!$this->trusted && !$module->safe) {
357 foreach ($module->info as
$name => $v) {
358 if (isset($elements[
$name])) {
367 foreach ($elements as
$n => $v) {
369 unset($elements[
$n]);
389 if (!isset($this->elementLookup[
$name])) {
401 foreach ($this->elementLookup[$name] as $module_name) {
402 $module = $this->modules[$module_name];
415 if (!
$def && $new_def->standalone) {
420 $def->mergeIn($new_def);
436 $this->attrCollections->performInclusions(
$def->attr);
437 $this->attrCollections->expandIdentifiers(
$def->attr, $this->attrTypes);
440 if (is_string(
$def->content_model) &&
441 strpos(
$def->content_model,
'Inline') !==
false) {
442 if ($name !=
'del' && $name !=
'ins') {
444 $def->descendants_are_inline =
true;
448 $this->contentSets->generateChildDef(
$def,
$module);
458 foreach (
$def->attr as $attr_name => $attr_def) {
459 if ($attr_def->required) {
460 $def->required_attr[] = $attr_name;
$attrCollections
HTMLPurifier_AttrCollections
$contentSets
HTMLPurifier_ContentSets
$trusted
If set to true, unsafe elements and attributes will be allowed.
$doctypes
HTMLPurifier_DoctypeRegistry
processModule($module)
Takes a module and adds it to the active module collection, registering it if necessary.
$registeredModules
Array of recognized HTMLPurifier_HTMLModule instances, indexed by module's class name.
if($modEnd===false) $module
registerModule($module, $overload=false)
Registers a module to the recognized module list, useful for overloading pre-existing modules...
setup($config)
Performs processing on modules, after being called you may use getElement() and getElements() ...
getElements()
Retrieves merged element definitions.
getElement($name, $trusted=null)
Retrieves a single merged element definition.
$modules
Active instances of modules for the specified doctype are indexed, by name, in this array...
addPrefix($prefix)
Adds a class prefix that registerModule() will use to resolve a string name to a concrete class...
Create styles array
The data for the language used.
addModule($module)
Adds a module to the current doctype by first registering it, and then tacking it on to the active do...
$userModules
List of extra modules that were added by the user using addModule().
$elementLookup
Associative array of element name to list of modules that have definitions for the element; this arra...
Defines common attribute collections that modules reference.
Provides lookup array of attribute types to HTMLPurifier_AttrDef objects.
$attrTypes
HTMLPurifier_AttrTypes
$doctype
Instance of current doctype.
$prefixes
List of prefixes we should use for registering small names.