From 9eaa6a2c0843397f8d5b2a896cbd87e1f7fb5ddc Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 10 Jul 2021 07:40:39 +0000 Subject: [PATCH] Use "convertForUriId" when possible --- blogger/blogger.php | 2 +- dwpost/dwpost.php | 2 +- ijpost/ijpost.php | 2 +- ljpost/ljpost.php | 2 +- mailstream/mailstream.php | 2 +- pumpio/pumpio.php | 2 +- tumblr/tumblr.php | 12 ++++++------ windowsphonepush/windowsphonepush.php | 4 ++-- wppost/wppost.php | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/blogger/blogger.php b/blogger/blogger.php index 5cf0d27b..38470f18 100644 --- a/blogger/blogger.php +++ b/blogger/blogger.php @@ -186,7 +186,7 @@ function blogger_send(App $a, array &$b) if ($bl_username && $bl_password && $bl_blog) { $title = '' . (($b['title']) ? $b['title'] : DI::l10n()->t('Post from Friendica')) . ''; - $post = $title . BBCode::convert($b['body']); + $post = $title . BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS); $post = XML::escape($post); $xml = <<< EOT diff --git a/dwpost/dwpost.php b/dwpost/dwpost.php index ce4d9096..56e04f78 100644 --- a/dwpost/dwpost.php +++ b/dwpost/dwpost.php @@ -183,7 +183,7 @@ function dwpost_send(App $a, array &$b) if ($dw_username && $dw_password && $dw_blog) { $title = $b['title']; - $post = BBCode::convert($b['body']); + $post = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS); $post = XML::escape($post); $tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]); diff --git a/ijpost/ijpost.php b/ijpost/ijpost.php index 15f2b41e..aad2a696 100644 --- a/ijpost/ijpost.php +++ b/ijpost/ijpost.php @@ -178,7 +178,7 @@ function ijpost_send(&$a, &$b) if ($ij_username && $ij_password && $ij_blog) { $title = $b['title']; - $post = BBCode::convert($b['body']); + $post = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS); $post = XML::escape($post); $tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]); diff --git a/ljpost/ljpost.php b/ljpost/ljpost.php index be831fa5..0cab2aa4 100644 --- a/ljpost/ljpost.php +++ b/ljpost/ljpost.php @@ -180,7 +180,7 @@ function ljpost_send(&$a,&$b) { if($lj_username && $lj_password && $lj_blog) { $title = XML::escape($b['title']); - $post = BBCode::convert($b['body']); + $post = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS); $post = XML::escape($post); $tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]); diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index d825979b..a9fbc2b4 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -401,7 +401,7 @@ function mailstream_send($message_id, $item, $user) $mail->CharSet = 'utf-8'; $template = Renderer::getMarkupTemplate('mail.tpl', 'addon/mailstream/'); $mail->AltBody = BBCode::toPlaintext($item['body']); - $item['body'] = BBCode::convert($item['body'], false, BBCode::CONNECTORS); + $item['body'] = BBCode::convertForUriId($item['uri-id'], $item['body'], BBCode::CONNECTORS); $item['url'] = DI::baseUrl()->get() . '/display/' . $item['guid']; $mail->Body = Renderer::replaceMacros($template, [ '$upstream' => DI::l10n()->t('Upstream'), diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 5f03c6c5..be2c5587 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -514,7 +514,7 @@ function pumpio_send(App $a, array &$b) if ($oauth_token && $oauth_token_secret) { $title = trim($b['title']); - $content = BBCode::convert($b['body'], false, BBCode::CONNECTORS); + $content = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS); $params = []; diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index 3dc89a37..4be767f9 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -415,7 +415,7 @@ function tumblr_send(App $a, array &$b) { switch ($siteinfo["type"]) { case "photo": $params['type'] = "photo"; - $params['caption'] = BBCode::convert($body, false, BBCode::CONNECTORS); + $params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS);; if (isset($siteinfo["url"])) { $params['link'] = $siteinfo["url"]; @@ -428,25 +428,25 @@ function tumblr_send(App $a, array &$b) { $params['type'] = "link"; $params['title'] = $title; $params['url'] = $siteinfo["url"]; - $params['description'] = BBCode::convert($body, false, BBCode::CONNECTORS); + $params['description'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS); break; case "audio": $params['type'] = "audio"; $params['external_url'] = $siteinfo["url"]; - $params['caption'] = BBCode::convert($body, false, BBCode::CONNECTORS); + $params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS); break; case "video": $params['type'] = "video"; $params['embed'] = $siteinfo["url"]; - $params['caption'] = BBCode::convert($body, false, BBCode::CONNECTORS); + $params['caption'] = BBCode::convertForUriId($b['uri-id'], $body, BBCode::CONNECTORS); break; default: $params['type'] = "text"; $params['title'] = $title; - $params['body'] = BBCode::convert($b['body'], false, BBCode::CONNECTORS); + $params['body'] = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS); break; } @@ -456,7 +456,7 @@ function tumblr_send(App $a, array &$b) { } if (empty($params['caption']) && !empty($siteinfo["description"])) { - $params['caption'] = BBCode::convert("[quote]" . $siteinfo["description"] . "[/quote]", false, BBCode::CONNECTORS); + $params['caption'] = BBCode::convertForUriId($b['uri-id'], "[quote]" . $siteinfo["description"] . "[/quote]", BBCode::CONNECTORS); } $consumer_key = DI::config()->get('tumblr','consumer_key'); diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index bf160f0a..12bc5c99 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -185,7 +185,7 @@ function windowsphonepush_cron() $senditemtext = DI::pConfig()->get($rr['uid'], 'windowsphonepush', 'senditemtext'); if ($senditemtext == 1) { // load item with the max id - $item = Post::selectFirst(['author-name', 'body'], ['id' => $count[0]['max']]); + $item = Post::selectFirst(['author-name', 'body', 'uri-id'], ['id' => $count[0]['max']]); // as user allows to send the item, we want to show the sender of the item in the toast // toasts are limited to one line, therefore place is limited - author shall be in @@ -201,7 +201,7 @@ function windowsphonepush_cron() if (substr($body, 0, 4) == "[url") { $body = "URL/Image ..."; } else { - $body = BBCode::convert($body, false, BBCode::API, true); + $body = BBCode::convertForUriId($item['uri-id'], $body, BBCode::API); $body = HTML::toPlaintext($body, 0); $body = ((strlen($body) > 137) ? substr($body, 0, 137) . "..." : $body); } diff --git a/wppost/wppost.php b/wppost/wppost.php index 1d24dbcf..637394d8 100644 --- a/wppost/wppost.php +++ b/wppost/wppost.php @@ -276,7 +276,7 @@ function wppost_send(&$a, &$b) // Remove the share element before fetching the first line $title = trim(preg_replace("/\[share.*?\](.*?)\[\/share\]/ism", "\n$1\n", $b['body'])); - $title = HTML::toPlaintext(BBCode::convert($title, false), 0, true)."\n"; + $title = BBCode::toPlaintext($title)."\n"; $pos = strpos($title, "\n"); $trailer = ""; if (($pos == 0) || ($pos > 100)) { @@ -289,7 +289,7 @@ function wppost_send(&$a, &$b) } $title = '' . (($wptitle) ? $wptitle : DI::l10n()->t('Post from Friendica')) . ''; - $post = BBCode::convert($b['body'], false, BBCode::CONNECTORS); + $post = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS); // If a link goes to youtube then remove the stuff around it. Wordpress detects youtube links and embeds it $post = preg_replace('/(.*?)<\/a>/ism', "\n$1\n", $post); -- 2.39.5