From 747c91210ff31d8ff42bb01d6c9f0fb5becc9085 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sun, 28 Feb 2016 13:30:47 +0100 Subject: [PATCH] HTMLPurifier cache settings, put stuff in subdir of get_sys_temp_dir() --- lib/default.php | 8 ++++++-- lib/util.php | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/default.php b/lib/default.php index c78803da97..0fa8ce1678 100644 --- a/lib/default.php +++ b/lib/default.php @@ -296,11 +296,15 @@ $default = array('handle' => false, // whether to handle sessions ourselves 'debug' => false, // debugging output for sessions 'gc_limit' => 1000), // max sessions to expire at a time - 'htmlfilter' => array( // purify HTML through HTMLPurifier + 'htmlfilter' => [ // remove tags from user/remotely generated HTML if they are === true 'img' => true, 'video' => true, 'audio' => true, - ), + ], + 'htmlpurifier' => [ // configurable options for HTMLPurifier + 'Cache.DefinitionImpl' => 'Serializer', + 'Cache.SerializerPath' => implode(DIRECTORY_SEPARATOR, [sys_get_temp_dir(), 'gnusocial']), + ], 'notice' => array('contentlimit' => null, 'allowprivate' => false, // whether to allow users to "check the padlock" to publish notices available for their subscribers. diff --git a/lib/util.php b/lib/util.php index c175c6e9ae..5aeda6d750 100644 --- a/lib/util.php +++ b/lib/util.php @@ -600,6 +600,9 @@ function common_purify($html, array $args=array()) $cfg->set('URI.Base', $args['URI.Base']); // if null this is like unsetting it I presume $cfg->set('URI.MakeAbsolute', !is_null($args['URI.Base'])); // if we have a URI base, convert relative URLs to absolute ones. } + foreach (common_config('htmlpurifier') as $key=>$val) { + $cfg->set($key, $val); + } // Remove more elements than what the default filter removes, default in GNU social are remotely // linked resources such as img, video, audio