summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-02-24 22:16:17 +0000
committerBrion Vibber <brion@pobox.com>2010-02-24 22:16:17 +0000
commitec4899e6179f2d9b368e6fc04041dd72c2ac2596 (patch)
tree2b69013c063cd8153a736f607a66263ebc44b79c
parent01cfe86cd27eb302a69c5d6df8eddc4893b774c3 (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
-rw-r--r--lib/activity.php26
-rw-r--r--plugins/OStatus/README50
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php22
3 files changed, 66 insertions, 32 deletions
diff --git a/lib/activity.php b/lib/activity.php
index 33932ad0e..25727bf2b 100644
--- a/lib/activity.php
+++ b/lib/activity.php
@@ -167,16 +167,18 @@ class PoCo
PoCo::NS
);
- $formatted = ActivityUtils::childContent(
- $addressEl,
- PoCoAddress::FORMATTED,
- self::NS
- );
+ if (!empty($addressEl)) {
+ $formatted = ActivityUtils::childContent(
+ $addressEl,
+ PoCoAddress::FORMATTED,
+ self::NS
+ );
- if (!empty($formatted)) {
- $address = new PoCoAddress();
- $address->formatted = $formatted;
- return $address;
+ if (!empty($formatted)) {
+ $address = new PoCoAddress();
+ $address->formatted = $formatted;
+ return $address;
+ }
}
return null;
@@ -292,7 +294,7 @@ class ActivityUtils
* @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);
@@ -320,7 +322,7 @@ class ActivityUtils
* @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;
if (empty($els) || $els->length == 0) {
@@ -345,7 +347,7 @@ class ActivityUtils
* @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);
diff --git a/plugins/OStatus/README b/plugins/OStatus/README
index cbf3adbb9..09a59e349 100644
--- a/plugins/OStatus/README
+++ b/plugins/OStatus/README
@@ -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.
+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:
-* set feed icon avatar for actual profiles as well as for preview
-* use channel image and/or favicon for avatar?
-* garbage-collect subscriptions that are no longer being used
-* administrative way to kill 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?
+* fully functional l10n
+* redo non-OStatus feed support
+** rssCloud support?
+** possibly a polling daemon to support non-PuSH 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?
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);
}