From e461474290f87a1e783100435183cf67217dce1b Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 9 Sep 2018 18:33:14 -0400 Subject: [PATCH 1/9] Fix count being called on the wrong variable in mod/notes --- mod/notes.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/notes.php b/mod/notes.php index 68a870e9d6..01f283870e 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -70,8 +70,11 @@ function notes_content(App $a, $update = false) $count = 0; if (DBA::isResult($r)) { - $count = count($r); - $o .= conversation($a, DBA::toArray($r), 'notes', $update); + $notes = DBA::toArray($r); + + $count = count($notes); + + $o .= conversation($a, $notes, 'notes', $update); } $o .= alt_pager($a, $count); From 8b96a53fba794bfd11738772b51015a0390c056b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 11 Sep 2018 04:10:11 +0000 Subject: [PATCH 2/9] Burn notices, burn --- mod/bookmarklet.php | 4 ++++ mod/photos.php | 6 ++++-- mod/salmon.php | 8 ++++---- mod/webfinger.php | 2 +- src/Model/Profile.php | 2 +- src/Network/Probe.php | 44 +++++++++++++++++++++---------------------- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/mod/bookmarklet.php b/mod/bookmarklet.php index 21b2039c58..e1ae9aa64c 100644 --- a/mod/bookmarklet.php +++ b/mod/bookmarklet.php @@ -30,6 +30,10 @@ function bookmarklet_content(App $a) $page = normalise_link(System::baseUrl() . "/bookmarklet"); if (!strstr($referer, $page)) { + if (empty($_REQUEST["url"])) { + System::httpExit(400, ["title" => L10n::t('Bad Request')]); + } + $content = add_page_info($_REQUEST["url"]); $x = [ diff --git a/mod/photos.php b/mod/photos.php index 16af455997..e205d72c6d 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -212,7 +212,7 @@ function photos_post(App $a) } // Check if the user has responded to a delete confirmation query - if ($_REQUEST['canceled']) { + if (!empty($_REQUEST['canceled'])) { goaway($_SESSION['photo_return']); } @@ -762,12 +762,14 @@ function photos_post(App $a) $filesize = $ret['filesize']; $type = $ret['type']; $error = UPLOAD_ERR_OK; - } else { + } elseif (!empty($_FILES['userfile'])) { $src = $_FILES['userfile']['tmp_name']; $filename = basename($_FILES['userfile']['name']); $filesize = intval($_FILES['userfile']['size']); $type = $_FILES['userfile']['type']; $error = $_FILES['userfile']['error']; + } else { + $error = UPLOAD_ERR_NO_FILE; } if ($error !== UPLOAD_ERR_OK) { diff --git a/mod/salmon.php b/mod/salmon.php index d07b06004d..bd4b3773cb 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -41,14 +41,14 @@ function salmon_post(App $a, $xml = '') { $base = null; // figure out where in the DOM tree our data is hiding - if($dom->provenance->data) + if (!empty($dom->provenance->data)) $base = $dom->provenance; - elseif($dom->env->data) + elseif (!empty($dom->env->data)) $base = $dom->env; - elseif($dom->data) + elseif (!empty($dom->data)) $base = $dom; - if(! $base) { + if (empty($base)) { logger('unable to locate salmon data in xml '); System::httpExit(400); } diff --git a/mod/webfinger.php b/mod/webfinger.php index 6f49a8f28c..4f23db6d8f 100644 --- a/mod/webfinger.php +++ b/mod/webfinger.php @@ -23,7 +23,7 @@ function webfinger_content(App $a) $o = '

Webfinger Diagnostic

'; $o .= '
'; - $o .= 'Lookup address: '; + $o .= 'Lookup address: '; $o .= '
'; $o .= '

'; diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 29bc7e680d..3a014517da 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -361,7 +361,7 @@ class Profile if ($r) { $remote_url = $r[0]['url']; $message_path = preg_replace('=(.*)/profile/(.*)=ism', '$1/message/new/', $remote_url); - $wallmessage_link = $message_path . base64_encode($profile['addr']); + $wallmessage_link = $message_path . base64_encode(defaults($profile, 'addr', '')); } else if (!empty($profile['nickname'])) { $wallmessage_link = 'wallmessage/' . $profile['nickname']; } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index af2d1c9a16..75231f44ff 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -967,23 +967,23 @@ class Probe $hcard_url = ""; $data = []; foreach ($webfinger["links"] as $link) { - if (($link["rel"] == NAMESPACE_DFRN) && ($link["href"] != "")) { + if (($link["rel"] == NAMESPACE_DFRN) && !empty($link["href"])) { $data["network"] = Protocol::DFRN; - } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) { $data["url"] = $link["href"]; - } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) { $hcard_url = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) { $data["poco"] = $link["href"]; - } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://webfinger.net/rel/avatar") && !empty($link["href"])) { $data["photo"] = $link["href"]; - } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) { $data["baseurl"] = trim($link["href"], '/'); - } elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) { $data["guid"] = $link["href"]; - } elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) { + } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) { $data["pubkey"] = base64_decode($link["href"]); //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA")) @@ -1170,21 +1170,21 @@ class Probe $hcard_url = ""; $data = []; foreach ($webfinger["links"] as $link) { - if (($link["rel"] == "http://microformats.org/profile/hcard") && ($link["href"] != "")) { + if (($link["rel"] == "http://microformats.org/profile/hcard") && !empty($link["href"])) { $hcard_url = $link["href"]; - } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/seed_location") && !empty($link["href"])) { $data["baseurl"] = trim($link["href"], '/'); - } elseif (($link["rel"] == "http://joindiaspora.com/guid") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://joindiaspora.com/guid") && !empty($link["href"])) { $data["guid"] = $link["href"]; - } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && ($link["type"] == "text/html") && ($link["href"] != "")) { + } elseif (($link["rel"] == "http://webfinger.net/rel/profile-page") && (defaults($link, "type", "") == "text/html") && !empty($link["href"])) { $data["url"] = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_POCO) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_POCO) && !empty($link["href"])) { $data["poco"] = $link["href"]; - } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) { + } elseif (($link["rel"] == "salmon") && !empty($link["href"])) { $data["notify"] = $link["href"]; - } elseif (($link["rel"] == "diaspora-public-key") && ($link["href"] != "")) { + } elseif (($link["rel"] == "diaspora-public-key") && !empty($link["href"])) { $data["pubkey"] = base64_decode($link["href"]); //if (strstr($data["pubkey"], 'RSA ') || ($link["type"] == "RSA")) @@ -1272,15 +1272,15 @@ class Probe if (is_array($webfinger["links"])) { foreach ($webfinger["links"] as $link) { if (($link["rel"] == "http://webfinger.net/rel/profile-page") - && ($link["type"] == "text/html") + && (defaults($link, "type", "") == "text/html") && ($link["href"] != "") ) { $data["url"] = $link["href"]; - } elseif (($link["rel"] == "salmon") && ($link["href"] != "")) { + } elseif (($link["rel"] == "salmon") && !empty($link["href"])) { $data["notify"] = $link["href"]; - } elseif (($link["rel"] == NAMESPACE_FEED) && ($link["href"] != "")) { + } elseif (($link["rel"] == NAMESPACE_FEED) && !empty($link["href"])) { $data["poll"] = $link["href"]; - } elseif (($link["rel"] == "magic-public-key") && ($link["href"] != "")) { + } elseif (($link["rel"] == "magic-public-key") && !empty($link["href"])) { $pubkey = $link["href"]; if (substr($pubkey, 0, 5) === 'data:') { @@ -1436,7 +1436,7 @@ class Probe $data = []; foreach ($webfinger["links"] as $link) { if (($link["rel"] == "http://webfinger.net/rel/profile-page") - && ($link["type"] == "text/html") + && (defaults($link, "type", "") == "text/html") && ($link["href"] != "") ) { $data["url"] = $link["href"]; From f566db52d3b915871fb7c639130daca1746d3eaa Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 11 Sep 2018 08:04:14 +0000 Subject: [PATCH 3/9] And more notices ... --- src/Protocol/PortableContact.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 20ee77a07c..2939f69e55 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -1157,9 +1157,9 @@ class PortableContact if (isset($data['version'])) { $platform = "Mastodon"; - $version = $data['version']; - $site_name = $data['title']; - $info = $data['description']; + $version = defaults($data, 'version', ''); + $site_name = defaults($data, 'title', ''); + $info = defaults($data, 'description', ''); $network = Protocol::OSTATUS; } From 7529fc61dd9169368224a092bcdf7d3cfeee1982 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 11 Sep 2018 19:54:45 -0400 Subject: [PATCH 4/9] Fix introductions notifications links --- mod/notifications.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mod/notifications.php b/mod/notifications.php index acd49de063..3934a32357 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -132,6 +132,11 @@ function notifications_content(App $a) $notif_tpl = get_markup_template('notifications.tpl'); + $notif_show_lnk = [ + 'href' => ($show ? 'notifications/' . $notifs['ident'] : 'notifications/' . $notifs['ident'] . '?show=all' ), + 'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')), + ]; + // Process the data for template creation if (defaults($notifs, 'ident', '') === 'introductions') { $sugg = get_markup_template('suggestions.tpl'); @@ -303,11 +308,6 @@ function notifications_content(App $a) $notif_nocontent = L10n::t('No more %s notifications.', $notifs['ident']); } - $notif_show_lnk = [ - 'href' => ($show ? 'notifications/' . $notifs['ident'] : 'notifications/' . $notifs['ident'] . '?show=all' ), - 'text' => ($show ? L10n::t('Show unread') : L10n::t('Show all')), - ]; - $o .= replace_macros($notif_tpl, [ '$notif_header' => $notif_header, '$tabs' => $tabs, From 96d10c25e359b74d4b0bcab08c234625c0ecf031 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 12 Sep 2018 06:05:14 +0000 Subject: [PATCH 5/9] Issue 5733: Removing contacts does work now on the same machine as well --- mod/contacts.php | 7 +++++++ mod/dfrn_notify.php | 14 +++++++------- src/Protocol/DFRN.php | 5 +---- src/Worker/RemoveContact.php | 4 ++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mod/contacts.php b/mod/contacts.php index 68f68fec3b..69bf2b47f9 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -47,6 +47,11 @@ function contacts_init(App $a) if (!DBA::isResult($contact)) { $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => 0]); } + + // Don't display contacts that are about to be deleted + if (($contact['network'] == Protocol::PHANTOM)) { + $contact = false; + } } if (DBA::isResult($contact)) { @@ -719,6 +724,8 @@ function contacts_content(App $a, $update = 0) $sql_extra = " AND `blocked` = 0 "; } + $sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM); + $search = x($_GET, 'search') ? notags(trim($_GET['search'])) : ''; $nets = x($_GET, 'nets' ) ? notags(trim($_GET['nets'])) : ''; diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 666c388a4a..2f76b59b97 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -79,13 +79,13 @@ function dfrn_notify_post(App $a) { $condition = []; switch ($direction) { case (-1): - $condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id]; + $condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']]; break; case 0: - $condition = ['issued-id' => $dfrn_id, 'duplex' => true]; + $condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']]; break; case 1: - $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true]; + $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']]; break; default: System::xmlExit(3, 'Invalid direction'); @@ -287,15 +287,15 @@ function dfrn_notify_content(App $a) { $condition = []; switch ($direction) { case (-1): - $condition = ["`issued-id` = ? OR `dfrn-id` = ?", $dfrn_id, $dfrn_id]; + $condition = ["(`issued-id` = ? OR `dfrn-id` = ?) AND `uid` = ?", $dfrn_id, $dfrn_id, $user['uid']]; $my_id = $dfrn_id; break; case 0: - $condition = ['issued-id' => $dfrn_id, 'duplex' => true]; + $condition = ['issued-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']]; $my_id = '1:' . $dfrn_id; break; case 1: - $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true]; + $condition = ['dfrn-id' => $dfrn_id, 'duplex' => true, 'uid' => $user['uid']]; $my_id = '0:' . $dfrn_id; break; default: @@ -326,7 +326,7 @@ function dfrn_notify_content(App $a) { $pub_key = trim($importer['cpubkey']); $dplx = intval($importer['duplex']); - if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) { + if (!empty($prv_key) && empty($pub_key)) { openssl_private_encrypt($hash, $challenge, $prv_key); openssl_private_encrypt($id_str, $encrypted_id, $prv_key); } elseif (strlen($pub_key)) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index b207c3ca87..3832e38e16 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1280,10 +1280,7 @@ class DFRN } } - if (($contact['duplex'] && strlen($contact['pubkey'])) - || ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey'])) - || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey'])) - ) { + if (empty($contact['prvkey']) && !empty($contact['pubkey'])) { openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']); openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']); } else { diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index b07661b7a9..8f986eab11 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -13,8 +13,8 @@ require_once 'include/dba.php'; class RemoveContact { public static function execute($id) { - // Only delete if the contact is archived - $condition = ['archive' => true, 'network' => Protocol::PHANTOM, 'id' => $id]; + // Only delete if the contact is to be deleted + $condition = ['network' => Protocol::PHANTOM, 'id' => $id]; $r = DBA::exists('contact', $condition); if (!DBA::isResult($r)) { return; From 7daa46503d3f0cd970fce3769ad1e79c9cecc0ef Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 12 Sep 2018 06:13:04 +0000 Subject: [PATCH 6/9] Don't risk incompatibilities --- mod/dfrn_notify.php | 2 +- src/Protocol/DFRN.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 2f76b59b97..8a53ac09b6 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -326,7 +326,7 @@ function dfrn_notify_content(App $a) { $pub_key = trim($importer['cpubkey']); $dplx = intval($importer['duplex']); - if (!empty($prv_key) && empty($pub_key)) { + if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) { openssl_private_encrypt($hash, $challenge, $prv_key); openssl_private_encrypt($id_str, $encrypted_id, $prv_key); } elseif (strlen($pub_key)) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 3832e38e16..b207c3ca87 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1280,7 +1280,10 @@ class DFRN } } - if (empty($contact['prvkey']) && !empty($contact['pubkey'])) { + if (($contact['duplex'] && strlen($contact['pubkey'])) + || ($owner['page-flags'] == Contact::PAGE_COMMUNITY && strlen($contact['pubkey'])) + || ($contact['rel'] == Contact::SHARING && strlen($contact['pubkey'])) + ) { openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']); openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']); } else { From c4825a8b5305df009fb548321da423feb112cf20 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 12 Sep 2018 18:49:36 +0000 Subject: [PATCH 7/9] Fixing parentheses --- mod/contacts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/contacts.php b/mod/contacts.php index 69bf2b47f9..1604f0b660 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -49,7 +49,7 @@ function contacts_init(App $a) } // Don't display contacts that are about to be deleted - if (($contact['network'] == Protocol::PHANTOM)) { + if ($contact['network'] == Protocol::PHANTOM) { $contact = false; } } From 63b5cb4fc688f9da2984c4c10439dba3a432633a Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 13 Sep 2018 15:46:37 +0000 Subject: [PATCH 8/9] Issue 5721: Temporarily deactivate the picture upload from private mails --- view/js/main.js | 5 +++++ view/theme/frio/templates/prv_message.tpl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/view/js/main.js b/view/js/main.js index 4ccbc8044e..83086c82b0 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -81,6 +81,11 @@ $(function() { Dialog.doImageBrowser("comment", id); return; } + + if (bbcode == "imgprv") { + bbcode = "img"; + } + insertFormatting(bbcode, id); }); diff --git a/view/theme/frio/templates/prv_message.tpl b/view/theme/frio/templates/prv_message.tpl index 4c90dcae6d..9077c4d4c1 100644 --- a/view/theme/frio/templates/prv_message.tpl +++ b/view/theme/frio/templates/prv_message.tpl @@ -33,7 +33,7 @@