Add %HTML.TargetNoreferrer, which adds rel="noreferrer" when target attribute is set
[htmlpurifier.git] / library / HTMLPurifier / EntityLookup.php
blobf12ff13a35a5f6e05c2b3e02688e0dad0df6005e
1 <?php
3 /**
4 * Object that provides entity lookup table from entity name to character
5 */
6 class HTMLPurifier_EntityLookup
8 /**
9 * Assoc array of entity name to character represented.
10 * @type array
12 public $table;
14 /**
15 * Sets up the entity lookup table from the serialized file contents.
16 * @param bool $file
17 * @note The serialized contents are versioned, but were generated
18 * using the maintenance script generate_entity_file.php
19 * @warning This is not in constructor to help enforce the Singleton
21 public function setup($file = false)
23 if (!$file) {
24 $file = HTMLPURIFIER_PREFIX . '/HTMLPurifier/EntityLookup/entities.ser';
26 $this->table = unserialize(file_get_contents($file));
29 /**
30 * Retrieves sole instance of the object.
31 * @param bool|HTMLPurifier_EntityLookup $prototype Optional prototype of custom lookup table to overload with.
32 * @return HTMLPurifier_EntityLookup
34 public static function instance($prototype = false)
36 // no references, since PHP doesn't copy unless modified
37 static $instance = null;
38 if ($prototype) {
39 $instance = $prototype;
40 } elseif (!$instance) {
41 $instance = new HTMLPurifier_EntityLookup();
42 $instance->setup();
44 return $instance;
48 // vim: et sw=4 sts=4