diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bb2diaspora.php | 8 | ||||
-rwxr-xr-x | include/diaspora.php | 89 |
2 files changed, 27 insertions, 70 deletions
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 622f239ad..9c8c05aeb 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -252,6 +252,7 @@ function bb2diaspora_itembody($item) { if($item['diaspora_meta']) { $j = json_decode($item['diaspora_meta'],true); if($j && $j['body']) { + logger('bb2diaspora_itembody: cached '); return $j['body']; } } @@ -299,6 +300,8 @@ function bb2diaspora_itembody($item) { } } + logger('bb2diaspora_itembody : ' . $body); + return html_entity_decode($body); } @@ -316,10 +319,7 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { 'return \'#\'. str_replace(\' \', \'_\', $match[3]);' ), $Text); - $Text = preg_replace_callback('/#\^\[([zu])rl\=(\w+.*?)\](\w+.*?)\[\/[(zu)]rl\]/i', create_function('$match', - 'return str_replace(\' \', \'_\', $match[3]);' - ), $Text); - + $Text = preg_replace('/#\^\[([zu])rl\=(\w+.*?)\](\w+.*?)\[\/([zu])rl\]/i', '[$1rl=$2]$3[/$4rl]', $Text); $Text = preg_replace_callback('/\@\!?\[([zu])rl\=(\w+.*?)\](\w+.*?)\[\/([zu])rl\]/i', 'bb2dmention_callback', $Text); diff --git a/include/diaspora.php b/include/diaspora.php index ae2c1184a..0b598ffb2 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2224,7 +2224,7 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { $images = array(); $title = $item['title']; - $body = $item['body']; + $body = bb2diaspora_itembody($item); /* // We're trying to match Diaspora's split message/photo protocol but @@ -2250,61 +2250,6 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { */ - $body = str_ireplace("[quote", "\n\n[quote", $body); - $body = str_ireplace("[/quote]", "[/quote]\n\n", $body); - - // strip bookmark indicators - - $body = preg_replace('/\#\^\[([zu])rl/i', '[$1rl', $body); - $body = preg_replace('/\#\^http/i', 'http', $body); - - // protect tags and mentions from hijacking - - if(! intval(get_pconfig($owner['channel_id'],'system','allow_tag_hijacking'))) { - $new_tag = html_entity_decode('⋕',ENT_COMPAT,'UTF-8'); - $new_mention = html_entity_decode('@',ENT_COMPAT,'UTF-8'); - - // #-tags - $body = preg_replace('/\#\[url/i', $new_tag . '[url', $body); - $body = preg_replace('/\#\[zrl/i', $new_tag . '[zrl', $body); - // @-mentions - $body = preg_replace('/\@\[url/i', $new_mention . '[url', $body); - $body = preg_replace('/\@\[zrl/i', $new_mention . '[zrl', $body); - } - - // remove multiple newlines - do { - $oldbody = $body; - $body = str_replace("\n\n\n", "\n\n", $body); - } while ($oldbody != $body); - - if($item['diaspora_meta']) { - $j = json_decode($item['diaspora_meta'],true); - if($j && $j['body']) { - $body = xmlify($j['body']); - } - } - else { - $body = xmlify(html_entity_decode(bb2diaspora($body))); - - - // convert to markdown - - // Adding the title - if(strlen($title)) - $body = "## ".html_entity_decode($title)."\n\n".$body; - - if($item['attach']) { - $cnt = preg_match_all('/href=\"(.*?)\"(.*?)title=\"(.*?)\"/ism',$item['attach'],$matches,PREG_SET_ORDER); - if(cnt) { - $body .= "\n" . t('Attachments:') . "\n"; - foreach($matches as $mtch) { - $body .= '[' . $mtch[3] . '](' . $mtch[1] . ')' . "\n"; - } - } - } - } - $public = (($item['item_private']) ? 'false' : 'true'); require_once('include/datetime.php'); @@ -2326,7 +2271,7 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { } else { $tpl = get_markup_template('diaspora_post.tpl'); $msg = replace_macros($tpl, array( - '$body' => $body, + '$body' => xmlify($body), '$guid' => $item['mid'], '$handle' => xmlify($myaddr), '$public' => $public, @@ -2480,16 +2425,28 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) { $like = false; } - $text = html_entity_decode(bb2diaspora($item['body'])); + if($item['diaspora_meta'] && ! $like) { + $j = json_decode($item['diaspora_meta'],true); + if($j) { + $signed_text = $j['signed_text']; + $text = $j['body']; + $signer = $j['signer']; + $authorsig = $j['signature']; + } + } + else { + $text = bb2diaspora_itembody($item); + + // sign it - // sign it + if($like) + $signed_text = $item['mid'] . ';' . $target_type . ';' . $parent['mid'] . ';' . $positive . ';' . $myaddr; + else + $signed_text = $item['mid'] . ';' . $parent['mid'] . ';' . $text . ';' . $myaddr; - if($like) - $signed_text = $item['mid'] . ';' . $target_type . ';' . $parent['mid'] . ';' . $positive . ';' . $myaddr; - else - $signed_text = $item['mid'] . ';' . $parent['mid'] . ';' . $text . ';' . $myaddr; + $authorsig = base64_encode(rsa_sign($signed_text,$owner['channel_prvkey'],'sha256')); - $authorsig = base64_encode(rsa_sign($signed_text,$owner['channel_prvkey'],'sha256')); + } $msg = replace_macros($tpl,array( '$guid' => xmlify($item['mid']), @@ -2516,9 +2473,9 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { $a = get_app(); $myaddr = $owner['channel_address'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); + $text = bb2diaspora_itembody($item); - $body = $item['body']; - $text = html_entity_decode(bb2diaspora($body)); + $body = $text; // Diaspora doesn't support threaded comments, but some // versions of Diaspora (i.e. Diaspora-pistos) support |