SN/T: don't cut off the body to avoid broken bbcode

This commit is contained in:
Tobias Diekershoff 2012-04-30 09:21:05 +02:00
parent 8b7b8fc49b
commit 47c11934de
2 changed files with 16 additions and 16 deletions

View File

@ -2,7 +2,7 @@
/** /**
* Name: StatusNet Connector * Name: StatusNet Connector
* Description: Relay public postings to a connected StatusNet account * Description: Relay public postings to a connected StatusNet account
* Version: 1.0.4 * Version: 1.0.5
* Author: Tobias Diekershoff <http://diekershoff.homeunix.net/friendika/profile/tobias> * Author: Tobias Diekershoff <http://diekershoff.homeunix.net/friendika/profile/tobias>
*/ */
@ -433,14 +433,14 @@ function statusnet_post_hook(&$a,&$b) {
// we can later send to StatusNet. This way we can "gain" some // we can later send to StatusNet. This way we can "gain" some
// information during shortening of potential links but do not // information during shortening of potential links but do not
// shorten all the links in a 200000 character long essay. // shorten all the links in a 200000 character long essay.
if (! $b['title']=='') { // if (! $b['title']=='') {
$tmp = $b['title'] . ' : '. $b['body']; // $tmp = $b['title'] . ' : '. $b['body'];
$tmp = substr($tmp, 0, 4*$max_char); // $tmp = substr($tmp, 0, 4*$max_char);
} else { // } else {
$tmp = substr($b['body'], 0, 3*$max_char); // $tmp = substr($b['body'], 0, 3*$max_char);
} // }
// if [url=bla][img]blub.png[/img][/url] get blub.png // if [url=bla][img]blub.png[/img][/url] get blub.png
$tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $tmp); $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $b['body']);
// preserve links to images, videos and audios // preserve links to images, videos and audios
$tmp = preg_replace( '/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism', '$3', $tmp); $tmp = preg_replace( '/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism', '$3', $tmp);
$tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp); $tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp);

View File

@ -2,7 +2,7 @@
/** /**
* Name: Twitter Connector * Name: Twitter Connector
* Description: Relay public postings to a connected Twitter account * Description: Relay public postings to a connected Twitter account
* Version: 1.0.3 * Version: 1.0.4
* Author: Tobias Diekershoff <http://diekershoff.homeunix.net/friendika/profile/tobias> * Author: Tobias Diekershoff <http://diekershoff.homeunix.net/friendika/profile/tobias>
*/ */
@ -299,14 +299,14 @@ function twitter_post_hook(&$a,&$b) {
// we can later send to Twitter. This way we can "gain" some // we can later send to Twitter. This way we can "gain" some
// information during shortening of potential links but do not // information during shortening of potential links but do not
// shorten all the links in a 200000 character long essay. // shorten all the links in a 200000 character long essay.
if (! $b['title']=='') { // if (! $b['title']=='') {
$tmp = $b['title'] . ' : '. $b['body']; // $tmp = $b['title'] . ' : '. $b['body'];
$tmp = substr($tmp, 0, 4*$max_char); // $tmp = substr($tmp, 0, 4*$max_char);
} else { // } else {
$tmp = substr($b['body'], 0, 3*$max_char); // $tmp = substr($b['body'], 0, 3*$max_char);
} // }
// if [url=bla][img]blub.png[/img][/url] get blub.png // if [url=bla][img]blub.png[/img][/url] get blub.png
$tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $tmp); $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $b['body']);
// preserve links to images, videos and audios // preserve links to images, videos and audios
$tmp = preg_replace( '/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism', '$3', $tmp); $tmp = preg_replace( '/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism', '$3', $tmp);
$tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp); $tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp);