From 7c60701efc091945dd2ee14728263d8dae0f88b0 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 10 Jun 2011 01:51:14 -0700 Subject: fixed a few feed problems affecting activity objects/targets --- include/items.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index dfe92378a..a5d430aa2 100644 --- a/include/items.php +++ b/include/items.php @@ -180,7 +180,11 @@ function construct_activity_object($item) { if($item['object']) { $o = '' . "\r\n"; - $r = parse_xml_string($item['object']); + $r = parse_xml_string($item['object'],false); + + + if(! $r) + return ''; if($r->type) $o .= '' . xmlify($r->type) . '' . "\r\n"; if($r->id) @@ -188,8 +192,15 @@ function construct_activity_object($item) { if($r->title) $o .= '' . xmlify($r->title) . '' . "\r\n"; if($r->link) { - if(substr($r->link,0,1) === '<') + if(substr($r->link,0,1) === '<') { + // patch up some facebook "like" activity objects that got stored incorrectly + // for a couple of months prior to 9-Jun-2011 and generated bad XML. + // we can probably remove this hack here and in the following function in a few months time. + if(strstr($r->link,'&') && (! strstr($r->link,'&'))) + $r->link = str_replace('&','&', $r->link); + $r->link = preg_replace('/\/','',$r->link); $o .= $r->link; + } else $o .= '' . "\r\n"; } @@ -206,7 +217,9 @@ function construct_activity_target($item) { if($item['target']) { $o = '' . "\r\n"; - $r = parse_xml_string($item['target']); + $r = parse_xml_string($item['target'],false); + if(! $r) + return ''; if($r->type) $o .= '' . xmlify($r->type) . '' . "\r\n"; if($r->id) @@ -214,8 +227,12 @@ function construct_activity_target($item) { if($r->title) $o .= '' . xmlify($r->title) . '' . "\r\n"; if($r->link) { - if(substr($r->link,0,1) === '<') + if(substr($r->link,0,1) === '<') { + if(strstr($r->link,'&') && (! strstr($r->link,'&'))) + $r->link = str_replace('&','&', $r->link); + $r->link = preg_replace('/\/','',$r->link); $o .= $r->link; + } else $o .= '' . "\r\n"; } -- cgit v1.2.3