/usr/share/php/HTMLPurifier/DefinitionCache/Decorator/Memory.php is in php-htmlpurifier 4.7.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <?php
/**
* Definition cache decorator class that saves all cache retrievals
* to PHP's memory; good for unit tests or circumstances where
* there are lots of configuration objects floating around.
*/
class HTMLPurifier_DefinitionCache_Decorator_Memory extends HTMLPurifier_DefinitionCache_Decorator
{
/**
* @type array
*/
protected $definitions;
/**
* @type string
*/
public $name = 'Memory';
/**
* @return HTMLPurifier_DefinitionCache_Decorator_Memory
*/
public function copy()
{
return new HTMLPurifier_DefinitionCache_Decorator_Memory();
}
/**
* @param HTMLPurifier_Definition $def
* @param HTMLPurifier_Config $config
* @return mixed
*/
public function add($def, $config)
{
$status = parent::add($def, $config);
if ($status) {
$this->definitions[$this->generateKey($config)] = $def;
}
return $status;
}
/**
* @param HTMLPurifier_Definition $def
* @param HTMLPurifier_Config $config
* @return mixed
*/
public function set($def, $config)
{
$status = parent::set($def, $config);
if ($status) {
$this->definitions[$this->generateKey($config)] = $def;
}
return $status;
}
/**
* @param HTMLPurifier_Definition $def
* @param HTMLPurifier_Config $config
* @return mixed
*/
public function replace($def, $config)
{
$status = parent::replace($def, $config);
if ($status) {
$this->definitions[$this->generateKey($config)] = $def;
}
return $status;
}
/**
* @param HTMLPurifier_Config $config
* @return mixed
*/
public function get($config)
{
$key = $this->generateKey($config);
if (isset($this->definitions[$key])) {
return $this->definitions[$key];
}
$this->definitions[$key] = parent::get($config);
return $this->definitions[$key];
}
}
// vim: et sw=4 sts=4
|