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

@ -167,16 +167,18 @@ class PoCo
PoCo::NS PoCo::NS
); );
$formatted = ActivityUtils::childContent( if (!empty($addressEl)) {
$addressEl, $formatted = ActivityUtils::childContent(
PoCoAddress::FORMATTED, $addressEl,
self::NS PoCoAddress::FORMATTED,
); self::NS
);
if (!empty($formatted)) { if (!empty($formatted)) {
$address = new PoCoAddress(); $address = new PoCoAddress();
$address->formatted = $formatted; $address->formatted = $formatted;
return $address; return $address;
}
} }
return null; return null;
@ -292,7 +294,7 @@ class ActivityUtils
* @return string related link, if any * @return string related link, if any
*/ */
static function getLink($element, $rel, $type=null) static function getLink(DOMNode $element, $rel, $type=null)
{ {
$links = $element->getElementsByTagnameNS(self::ATOM, self::LINK); $links = $element->getElementsByTagnameNS(self::ATOM, self::LINK);
@ -320,7 +322,7 @@ class ActivityUtils
* @return DOMElement found element or null * @return DOMElement found element or null
*/ */
static function child($element, $tag, $namespace=self::ATOM) static function child(DOMNode $element, $tag, $namespace=self::ATOM)
{ {
$els = $element->childNodes; $els = $element->childNodes;
if (empty($els) || $els->length == 0) { if (empty($els) || $els->length == 0) {
@ -345,7 +347,7 @@ class ActivityUtils
* @return string content of the child * @return string content of the child
*/ */
static function childContent($element, $tag, $namespace=self::ATOM) static function childContent(DOMNode $element, $tag, $namespace=self::ATOM)
{ {
$el = self::child($element, $tag, $namespace); $el = self::child($element, $tag, $namespace);

View File

@ -2,23 +2,37 @@ Plugin to support importing updates from external RSS and Atom feeds into your t
Uses PubSubHubbub for push feed updates; currently non-PuSH feeds cannot be subscribed. Uses PubSubHubbub for push feed updates; currently non-PuSH feeds cannot be subscribed.
Configuration options available:
$config['ostatus']['hub']
(default internal hub)
Set to URL of an external PuSH hub to use it instead of our internal hub.
$config['ostatus']['hub_retries']
(default 0)
Number of times to retry a PuSH send to consumers if using internal hub
$config['ostatus']['purify_cache']
(default cache disabled)
Set to a writable cache directory for HTMLPurifier's configuration settings, can speed up processing of remote messages (have not tested by how much)
For testing, shouldn't be used in production:
$config['ostatus']['skip_signatures']
(default use signatures)
Disable generation and validation of Salmon magicenv signatures
$config['feedsub']['nohub']
(default require hub)
Allow low-level feed subscription setup for feeds without hubs.
Not actually usable at this stage, OStatus will check for hubs too
and we have no polling backend.
Todo: Todo:
* set feed icon avatar for actual profiles as well as for preview * fully functional l10n
* use channel image and/or favicon for avatar? * redo non-OStatus feed support
* garbage-collect subscriptions that are no longer being used ** rssCloud support?
* administrative way to kill feeds? ** possibly a polling daemon to support non-PuSH feeds?
* functional l10n
* clean up subscription form look and workflow
* use ajax for test/preview in subscription form
* rssCloud support? (Does anything use it that doesn't support PuSH as well?)
* possibly a polling daemon to support non-PuSH feeds?
* likely problems with multiple feeds from the same site, such as category feeds on a blog
(currently each feed would publish a separate notice on a separate profile, but pointing to the same post URI.)
(could use the local URI I guess, but that's so icky!)
* problems with Atom feeds that list <link rel="alternate" href="..."/> but don't have the type
(such as http://atomgen.appspot.com/feed/5 demo feed); currently it's not recognized and we end up with the feed's master URI
* make it easier to see what you're subscribed to and unsub from things
* saner treatment of fullname/nickname?
* make use of tags/categories from feeds * make use of tags/categories from feeds
* update feed profile data when it changes
* XML_Feed_Parser has major problems with category and link tags; consider replacing?

View File

@ -668,9 +668,27 @@ class Ostatus_profile extends Memcached_DataObject
*/ */
protected function purify($html) protected function purify($html)
{ {
// @fixme disable caching or set a sane temp dir
require_once(INSTALLDIR.'/extlib/HTMLPurifier/HTMLPurifier.auto.php'); 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); return $purifier->purify($html);
} }