diff options
author | Brion Vibber <brion@pobox.com> | 2010-02-24 22:16:17 +0000 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-02-24 22:16:17 +0000 |
commit | ec4899e6179f2d9b368e6fc04041dd72c2ac2596 (patch) | |
tree | 2b69013c063cd8153a736f607a66263ebc44b79c /plugins/OStatus/classes/Ostatus_profile.php | |
parent | 01cfe86cd27eb302a69c5d6df8eddc4893b774c3 (diff) |
OStatus: disable HTMLPurify cache unless we've configured a writable path for it.
Updated plugin README with available config options.
Cleanup for a bad element fallback lookup in Activity
Diffstat (limited to 'plugins/OStatus/classes/Ostatus_profile.php')
-rw-r--r-- | plugins/OStatus/classes/Ostatus_profile.php | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 5e38a523e..c755a094e 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -668,9 +668,27 @@ class Ostatus_profile extends Memcached_DataObject */ protected function purify($html) { - // @fixme disable caching or set a sane temp dir require_once(INSTALLDIR.'/extlib/HTMLPurifier/HTMLPurifier.auto.php'); - $purifier = new HTMLPurifier(); + + // By default Purifier wants to cache data to its own code directories, + // and spews error messages if they're not writable. + $config = HTMLPurifier_Config::createDefault(); + if (common_config('ostatus', 'purify_cache')) { + $config->set('Cache.SerializerPath', common_config('ostatus', 'purify_cache')); + } else { + // Although recommended in the documentation, this produces a notice: + // "Core.DefinitionCache is an alias, preferred directive name is Cache.DefinitionImpl" + // If I then follow *those* directions, I get a warning and it doesn't work: + // "Cannot set undefined directive Core.DefinitionImpl" + // So... lesser of two evils. Suppressing the notice from output, + // though it'll still be seen and logged by StatusNet's error handler. + $old = error_reporting(); + error_reporting($old & ~E_NOTICE); + $config->set('Core.DefinitionCache', null); + error_reporting($old); + } + + $purifier = new HTMLPurifier($config); return $purifier->purify($html); } |