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
This commit is contained in:
Brion Vibber
2010-02-24 22:16:17 +00:00
parent 01cfe86cd2
commit ec4899e617
3 changed files with 66 additions and 32 deletions

View File

@@ -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);
}