mirror of
https://github.com/friendica/friendica
synced 2024-12-23 12:40:17 +00:00
fixed a few feed problems affecting activity objects/targets
This commit is contained in:
parent
b857a49bfe
commit
7c60701efc
4 changed files with 37 additions and 13 deletions
|
@ -908,7 +908,7 @@ function fb_consume_stream($uid,$j,$wall = false) {
|
||||||
|
|
||||||
$likedata['body'] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
|
$likedata['body'] = sprintf( t('%1$s likes %2$s\'s %3$s'), $author, $objauthor, $plink);
|
||||||
$likedata['object'] = '<object><type>' . ACTIVITY_OBJ_NOTE . '</type><local>1</local>' .
|
$likedata['object'] = '<object><type>' . ACTIVITY_OBJ_NOTE . '</type><local>1</local>' .
|
||||||
'<id>' . $orig_post['uri'] . '</id><link>' . xmlify('<link rel="alternate" type="text/html" href="' . $orig_post['plink'] . '">') . '</link><title>' . $orig_post['title'] . '</title><content>' . $orig_post['body'] . '</content></object>';
|
'<id>' . $orig_post['uri'] . '</id><link>' . xmlify('<link rel="alternate" type="text/html" href="' . xmlify($orig_post['plink']) . '" />') . '</link><title>' . $orig_post['title'] . '</title><content>' . $orig_post['body'] . '</content></object>';
|
||||||
|
|
||||||
$item = item_store($likedata);
|
$item = item_store($likedata);
|
||||||
}
|
}
|
||||||
|
|
11
boot.php
11
boot.php
|
@ -2788,16 +2788,23 @@ function lang_selector() {
|
||||||
|
|
||||||
|
|
||||||
if(! function_exists('parse_xml_string')) {
|
if(! function_exists('parse_xml_string')) {
|
||||||
function parse_xml_string($s) {
|
function parse_xml_string($s,$strict = true) {
|
||||||
|
if($strict) {
|
||||||
if(! strstr($s,'<?xml'))
|
if(! strstr($s,'<?xml'))
|
||||||
return false;
|
return false;
|
||||||
$s2 = substr($s,strpos($s,'<?xml'));
|
$s2 = substr($s,strpos($s,'<?xml'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$s2 = $s;
|
||||||
libxml_use_internal_errors(true);
|
libxml_use_internal_errors(true);
|
||||||
|
|
||||||
$x = @simplexml_load_string($s2);
|
$x = @simplexml_load_string($s2);
|
||||||
if(count(libxml_get_errors()))
|
if(! $x) {
|
||||||
|
logger('libxml: parse: error: ' . $s2, LOGGER_DATA);
|
||||||
foreach(libxml_get_errors() as $err)
|
foreach(libxml_get_errors() as $err)
|
||||||
logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA);
|
logger('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, LOGGER_DATA);
|
||||||
libxml_clear_errors();
|
libxml_clear_errors();
|
||||||
|
}
|
||||||
return $x;
|
return $x;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,11 @@ function construct_activity_object($item) {
|
||||||
|
|
||||||
if($item['object']) {
|
if($item['object']) {
|
||||||
$o = '<as:object>' . "\r\n";
|
$o = '<as:object>' . "\r\n";
|
||||||
$r = parse_xml_string($item['object']);
|
$r = parse_xml_string($item['object'],false);
|
||||||
|
|
||||||
|
|
||||||
|
if(! $r)
|
||||||
|
return '';
|
||||||
if($r->type)
|
if($r->type)
|
||||||
$o .= '<as:object-type>' . xmlify($r->type) . '</as:object-type>' . "\r\n";
|
$o .= '<as:object-type>' . xmlify($r->type) . '</as:object-type>' . "\r\n";
|
||||||
if($r->id)
|
if($r->id)
|
||||||
|
@ -188,8 +192,15 @@ function construct_activity_object($item) {
|
||||||
if($r->title)
|
if($r->title)
|
||||||
$o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
|
$o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
|
||||||
if($r->link) {
|
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('/\<link(.*?)\"\>/','<link$1"/>',$r->link);
|
||||||
$o .= $r->link;
|
$o .= $r->link;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
|
$o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
|
||||||
}
|
}
|
||||||
|
@ -206,7 +217,9 @@ function construct_activity_target($item) {
|
||||||
|
|
||||||
if($item['target']) {
|
if($item['target']) {
|
||||||
$o = '<as:target>' . "\r\n";
|
$o = '<as:target>' . "\r\n";
|
||||||
$r = parse_xml_string($item['target']);
|
$r = parse_xml_string($item['target'],false);
|
||||||
|
if(! $r)
|
||||||
|
return '';
|
||||||
if($r->type)
|
if($r->type)
|
||||||
$o .= '<as:object-type>' . xmlify($r->type) . '</as:object-type>' . "\r\n";
|
$o .= '<as:object-type>' . xmlify($r->type) . '</as:object-type>' . "\r\n";
|
||||||
if($r->id)
|
if($r->id)
|
||||||
|
@ -214,8 +227,12 @@ function construct_activity_target($item) {
|
||||||
if($r->title)
|
if($r->title)
|
||||||
$o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
|
$o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n";
|
||||||
if($r->link) {
|
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('/\<link(.*?)\"\>/','<link$1"/>',$r->link);
|
||||||
$o .= $r->link;
|
$o .= $r->link;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
|
$o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,8 +159,8 @@ function events_post(&$a) {
|
||||||
$arr['body'] = format_event_bbcode($event);
|
$arr['body'] = format_event_bbcode($event);
|
||||||
|
|
||||||
|
|
||||||
$arr['object'] = '<object><type>' . ACTIVITY_OBJ_EVENT . '</type><title></title><id>' . $uri . '</id>';
|
$arr['object'] = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($uri) . '</id>';
|
||||||
$arr['object'] .= '<content>' . format_event_bbcode($event) . '</content>';
|
$arr['object'] .= '<content>' . xmlify(format_event_bbcode($event)) . '</content>';
|
||||||
$arr['object'] .= '</object>' . "\n";
|
$arr['object'] .= '</object>' . "\n";
|
||||||
|
|
||||||
$item_id = item_store($arr);
|
$item_id = item_store($arr);
|
||||||
|
|
Loading…
Reference in a new issue