From 2e75e37c932266f71c515839d1044e4677760c1f Mon Sep 17 00:00:00 2001
From: Michael Vogel
Date: Thu, 7 Aug 2014 21:55:17 +0200
Subject: [PATCH 1/3] There seems to be problems with encoding - this should
fix it.
---
include/bbcode.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/bbcode.php b/include/bbcode.php
index 571809c3b..df2c7101b 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -1076,7 +1076,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
- //$Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8");
+ $Text = mb_convert_encoding($Text, 'HTML-ENTITIES', "UTF-8");
$doctype = '';
$encoding = '';
From b99737986d2a2e7deb8836ab887a77af24a4925e Mon Sep 17 00:00:00 2001
From: Michael Vogel
Date: Sat, 9 Aug 2014 09:17:28 +0200
Subject: [PATCH 2/3] The GUID in the link to the items has to be encoded,
since it could contain special characters
---
include/diaspora.php | 5 ++---
include/items.php | 17 ++++++-----------
mod/item.php | 12 ++++--------
3 files changed, 12 insertions(+), 22 deletions(-)
diff --git a/include/diaspora.php b/include/diaspora.php
index 0eeacc487..8b85e7b95 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -1423,8 +1423,7 @@ function diaspora_comment($importer,$xml,$msg) {
'to_email' => $importer['email'],
'uid' => $importer['uid'],
'item' => $datarray,
- //'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id,
- 'link' => $a->get_baseurl().'/display/'.$datarray['guid'],
+ 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
@@ -1960,7 +1959,7 @@ EOT;
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $parent_item['author-link'] . ']' . $parent_item['author-name'] . '[/url]';
//$plink = '[url=' . $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $parent_item['id'] . ']' . $post_type . '[/url]';
- $plink = '[url='.$a->get_baseurl().'/display/'.$guid.']'.$post_type.'[/url]';
+ $plink = '[url='.$a->get_baseurl().'/display/'.urlencode($guid).']'.$post_type.'[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
$arr['app'] = 'Diaspora';
diff --git a/include/items.php b/include/items.php
index 6a72320cd..fbbc5e7ae 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1117,7 +1117,7 @@ function item_store($arr,$force_parent = false) {
if ($arr['plink'] == "") {
$a = get_app();
- $arr['plink'] = $a->get_baseurl().'/display/'.$arr['guid'];
+ $arr['plink'] = $a->get_baseurl().'/display/'.urlencode($arr['guid']);
}
if ($arr['network'] == "") {
@@ -1298,8 +1298,7 @@ function item_store($arr,$force_parent = false) {
'to_email' => $u[0]['email'],
'uid' => $u[0]['uid'],
'item' => $item[0],
- //'link' => $a->get_baseurl().'/display/'.$u[0]['nickname'].'/'.$current_post,
- 'link' => $a->get_baseurl().'/display/'.$arr['guid'],
+ 'link' => $a->get_baseurl().'/display/'.urlencode($arr['guid']),
'source_name' => $item[0]['author-name'],
'source_link' => $item[0]['author-link'],
'source_photo' => $item[0]['author-avatar'],
@@ -1563,8 +1562,7 @@ function tag_deliver($uid,$item_id) {
'to_email' => $u[0]['email'],
'uid' => $u[0]['uid'],
'item' => $item,
- //'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item['id'],
- 'link' => $a->get_baseurl() . '/display/'.get_item_guid($item['id']),
+ 'link' => $a->get_baseurl() . '/display/'.urlencode(get_item_guid($item['id'])),
'source_name' => $item['author-name'],
'source_link' => $item['author-link'],
'source_photo' => $photo,
@@ -3379,8 +3377,7 @@ function local_delivery($importer,$data) {
'to_email' => $importer['email'],
'uid' => $importer['importer_uid'],
'item' => $datarray,
- //'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id,
- 'link' => $a->get_baseurl().'/display/'.get_item_guid($posted_id),
+ 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($posted_id)),
'source_name' => stripslashes($datarray['author-name']),
'source_link' => $datarray['author-link'],
'source_photo' => ((link_compare($datarray['author-link'],$importer['url']))
@@ -3544,8 +3541,7 @@ function local_delivery($importer,$data) {
'to_email' => $importer['email'],
'uid' => $importer['importer_uid'],
'item' => $datarray,
- //'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id,
- 'link' => $a->get_baseurl().'/display/'.get_item_guid($posted_id),
+ 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($posted_id)),
'source_name' => stripslashes($datarray['author-name']),
'source_link' => $datarray['author-link'],
'source_photo' => ((link_compare($datarray['author-link'],$importer['url']))
@@ -3698,8 +3694,7 @@ function local_delivery($importer,$data) {
'to_email' => $importer['email'],
'uid' => $importer['importer_uid'],
'item' => $datarray,
- //'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id,
- 'link' => $a->get_baseurl().'/display/'.get_item_guid($posted_id),
+ 'link' => $a->get_baseurl().'/display/'.urlencode(get_item_guid($posted_id)),
'source_name' => stripslashes($datarray['author-name']),
'source_link' => $datarray['author-link'],
'source_photo' => ((link_compare($datarray['author-link'],$importer['url']))
diff --git a/mod/item.php b/mod/item.php
index 901fb3385..9be9de668 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -847,8 +847,7 @@ function item_post(&$a) {
'to_email' => $user['email'],
'uid' => $user['uid'],
'item' => $datarray,
- //'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
- 'link' => $a->get_baseurl().'/display/'.$datarray['guid'],
+ 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
@@ -876,8 +875,7 @@ function item_post(&$a) {
'to_email' => $user['email'],
'uid' => $user['uid'],
'item' => $datarray,
- //'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
- 'link' => $a->get_baseurl().'/display/'.$datarray['guid'],
+ 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']),
'source_name' => $datarray['author-name'],
'source_link' => $datarray['author-link'],
'source_photo' => $datarray['author-avatar'],
@@ -896,8 +894,7 @@ function item_post(&$a) {
WHERE `id` = %d",
intval($parent),
dbesc(($parent == $post_id) ? $uri : $parent_item['uri']),
- //dbesc($a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id),
- dbesc($a->get_baseurl().'/display/'.$datarray['guid']),
+ dbesc($a->get_baseurl().'/display/'.urlencode($datarray['guid'])),
dbesc(datetime_convert()),
intval($post_id)
);
@@ -930,8 +927,7 @@ function item_post(&$a) {
update_thread($parent);
$datarray['id'] = $post_id;
- //$datarray['plink'] = $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id;
- $datarray['plink'] = $a->get_baseurl().'/display/'.$datarray['guid'];
+ $datarray['plink'] = $a->get_baseurl().'/display/'.urlencode($datarray['guid']);
call_hooks('post_local_end', $datarray);
From 731d944ab596145c421f239fc132f3beb74de21b Mon Sep 17 00:00:00 2001
From: Michael Vogel
Date: Sat, 9 Aug 2014 09:20:37 +0200
Subject: [PATCH 3/3] bb2diaspora: added one more page break. In the future it
could be replaced by a regular expression.
---
include/bb2diaspora.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index b70a05661..39742291f 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -21,7 +21,7 @@ function diaspora2bb($s) {
$s = str_replace("\r","",$s);
//
is invalid. Replace it with the valid expression
- $s = str_replace(array("
", "
", ""),array("
", "
", "
"),$s);
+ $s = str_replace(array("
", "
", "", '
'),array("
", "
", "
", "
"),$s);
$s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s);