From 21c03fb5220d2190a8a764d5430c6fa8bc013860 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 25 Aug 2011 16:37:27 -0700 Subject: [PATCH] diaspora2bb, salmon fix argument error --- boot.php | 2 +- include/bb2diaspora.php | 19 +++++++++++++++ include/diaspora.php | 54 ++--------------------------------------- include/salmon.php | 6 ++--- 4 files changed, 25 insertions(+), 56 deletions(-) diff --git a/boot.php b/boot.php index eddcdf1530..e897f19aa1 100644 --- a/boot.php +++ b/boot.php @@ -7,7 +7,7 @@ require_once('include/text.php'); require_once("include/pgettext.php"); -define ( 'FRIENDIKA_VERSION', '2.2.1082' ); +define ( 'FRIENDIKA_VERSION', '2.2.1083' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); define ( 'DB_UPDATE_VERSION', 1082 ); diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 5ce34d6660..7f7b8748d3 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -5,6 +5,25 @@ require_once('include/event.php'); + +function diaspora2bb($s) { + + $s = str_replace(array('\\**','\\__','\\*','\\_'), array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'),$s); + $s = preg_replace("/\*\*\*(.+?)\*\*\*/", '[b][i]$1[/i][/b]', $s); + $s = preg_replace("/\_\_\_(.+?)\_\_\_/", '[b][i]$1[/i][/b]', $s); + $s = preg_replace("/\*\*(.+?)\*\*/", '[b]$1[/b]', $s); + $s = preg_replace("/\_\_(.+?)\_\_/", '[b]$1[/b]', $s); + $s = preg_replace("/\*(.+?)\*/", '[i]$1[/i]', $s); + $s = preg_replace("/\_(.+?)\_/", '[i]$1[/i]', $s); + $s = str_replace(array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'), array('**','__','*','_'), $s); + $s = preg_replace('/\[(.+?)\]\((.+?)\)/','[url=$2]$1[/url]',$s); + + $s = escape_tags($s); + return $s; + +} + + function stripdcode_br_cb($s) { return '[code]' . str_replace('
', '', $s[1]) . '[/code]'; } diff --git a/include/diaspora.php b/include/diaspora.php index 75d47e05aa..90c802363c 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -435,32 +435,7 @@ function diaspora_post($importer,$xml) { $created = unxmlify($xml->created_at); $private = ((unxmlify($xml->public) == 'false') ? 1 : 0); - $body = unxmlify($xml->raw_message); - - require_once('library/HTMLPurifier.auto.php'); - require_once('include/html2bbcode.php'); - - $maxlen = get_max_import_size(); - if($maxlen && (strlen($body) > $maxlen)) - $body = substr($body,0, $maxlen); - - if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { - - $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $body); - - $body = preg_replace('#].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $body); - - $body = oembed_html2bbcode($body); - - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.DefinitionImpl', null); - $purifier = new HTMLPurifier($config); - $body = $purifier->purify($body); - - $body = html2bbcode($body); - } + $body = diaspora2bb($xml->raw_message); $datarray = array(); $datarray['uid'] = $importer['uid']; @@ -558,32 +533,7 @@ function diaspora_comment($importer,$xml,$msg) { // Phew! Everything checks out. Now create an item. - require_once('library/HTMLPurifier.auto.php'); - require_once('include/html2bbcode.php'); - - $body = $text; - - $maxlen = get_max_import_size(); - if($maxlen && (strlen($body) > $maxlen)) - $body = substr($body,0, $maxlen); - - if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { - - $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $body); - - $body = preg_replace('#].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?#s', - '[youtube]$1[/youtube]', $body); - - $body = oembed_html2bbcode($body); - - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.DefinitionImpl', null); - $purifier = new HTMLPurifier($config); - $body = $purifier->purify($body); - - $body = html2bbcode($body); - } + $body = diaspora2bb($text); $message_id = $diaspora_handle . ':' . $guid; diff --git a/include/salmon.php b/include/salmon.php index ba61fffcca..9153f8994c 100644 --- a/include/salmon.php +++ b/include/salmon.php @@ -109,11 +109,11 @@ EOT; $precomputed = '.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng=='; - $signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),true),$owner['sprvkey']); + $signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),$owner['sprvkey'])); - $signature2 = base64url_encode(rsa_sign($data . $precomputed),$owner['sprvkey']); + $signature2 = base64url_encode(rsa_sign($data . $precomputed,$owner['sprvkey'])); - $signature3 = base64url_encode(rsa_sign($data),$owner['sprvkey']); + $signature3 = base64url_encode(rsa_sign($data,$owner['sprvkey'])); $salmon_tpl = get_markup_template('magicsig.tpl');