diff options
author | Friendika <info@friendika.com> | 2011-08-25 16:37:27 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-08-25 16:37:27 -0700 |
commit | 21c03fb5220d2190a8a764d5430c6fa8bc013860 (patch) | |
tree | a5739e2c79eb2564053aacf939f1b9d218cf09dc /include | |
parent | 1b33ba6587766d939ac37c1ca60aa5c012e4da9d (diff) | |
download | volse-hubzilla-21c03fb5220d2190a8a764d5430c6fa8bc013860.tar.gz volse-hubzilla-21c03fb5220d2190a8a764d5430c6fa8bc013860.tar.bz2 volse-hubzilla-21c03fb5220d2190a8a764d5430c6fa8bc013860.zip |
diaspora2bb, salmon fix argument error
Diffstat (limited to 'include')
-rw-r--r-- | include/bb2diaspora.php | 19 | ||||
-rw-r--r-- | include/diaspora.php | 54 | ||||
-rw-r--r-- | include/salmon.php | 6 |
3 files changed, 24 insertions, 55 deletions
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 5ce34d666..7f7b8748d 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('<br />', '', $s[1]) . '[/code]'; } diff --git a/include/diaspora.php b/include/diaspora.php index 75d47e05a..90c802363 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('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s', - '[youtube]$1[/youtube]', $body); - - $body = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#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('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s', - '[youtube]$1[/youtube]', $body); - - $body = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#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 ba61fffcc..9153f8994 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'); |