From 30151357503764feecdcdc1443e475bcaef7bd1c Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 29 May 2019 19:54:25 +0200 Subject: [PATCH 1/9] Adding fallback route in case of a non valid route see https://github.com/friendica/friendica/issues/6918#issuecomment-491009954 --- mod/notifications.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mod/notifications.php b/mod/notifications.php index ff954d4189..8bc9a76c38 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -121,6 +121,9 @@ function notifications_content(App $a) } elseif (($a->argc > 1) && ($a->argv[1] == 'home')) { $notif_header = L10n::t('Home Notifications'); $notifs = $nm->homeNotifs($show, $startrec, $perpage); + // fallback - redirect to main page + } else { + $a->internalRedirect('notifications'); } // Set the pager From e853e256c73b9bf2a65a35a84132b8c0bf3dfec3 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 29 May 2019 19:55:18 +0200 Subject: [PATCH 2/9] Checking all values for $_SESSION See https://github.com/friendica/friendica/issues/6918#issuecomment-491492826 --- mod/redir.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mod/redir.php b/mod/redir.php index 4dbae5498b..931e07c770 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -7,8 +7,8 @@ use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\Profile; -use Friendica\Util\Strings; use Friendica\Util\Network; +use Friendica\Util\Strings; function redir_init(App $a) { @@ -70,7 +70,10 @@ function redir_init(App $a) { && is_array($_SESSION['remote'])) { foreach ($_SESSION['remote'] as $v) { - if ($v['uid'] == $_SESSION['visitor_visiting'] && $v['cid'] == $_SESSION['visitor_id']) { + if (!empty($v['uid']) && !empty($_SESSION['visitor_visiting']) && + !empty($v['cid']) && !empty($_SESSION['visitor_id']) && + $v['uid'] == $_SESSION['visitor_visiting'] && + $v['cid'] == $_SESSION['visitor_id']) { // Remote user is already authenticated. $target_url = defaults($url, $contact_url); Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG); From 5002bda5fcfa2c0d9e1549869866effba35cf14b Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 29 May 2019 19:56:18 +0200 Subject: [PATCH 3/9] Checking the existence of '-' before array operation See https://github.com/friendica/friendica/issues/6918#issuecomment-491490533 --- src/Module/Admin/Federation.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index f32f0e2ccd..9c52845b93 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -87,7 +87,9 @@ class Federation extends BaseAdminModule $part = array_pop($parts); } while (!empty($parts) && ((strlen($part) >= 40) || (strlen($part) <= 3))); // only take the x.x.x part of the version, not the "release" after the dash - $part = array_shift(explode('-', $part)); + if (!empty($part) && strpos($part, '-')) { + $part = array_shift(explode('-', $part)); + } if (!empty($part)) { if (empty($compacted[$part])) { $compacted[$part] = $versionCounts[$key]['total']; From 15ffb70c5f631d85b9a79a12b847227bd222f040 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 29 May 2019 19:57:18 +0200 Subject: [PATCH 4/9] Adding `item_id` to Item::ITEM_FIELDLIST see https://github.com/friendica/friendica/issues/6918#issuecomment-493515358 --- src/Model/Item.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index a01ff61143..865aa4ffc7 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -11,9 +11,9 @@ use Friendica\Content\Text\BBCode; use Friendica\Content\Text\HTML; use Friendica\Core\Config; use Friendica\Core\Hook; +use Friendica\Core\L10n; use Friendica\Core\Lock; use Friendica\Core\Logger; -use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\Protocol; use Friendica\Core\Renderer; @@ -24,10 +24,10 @@ use Friendica\Protocol\Diaspora; use Friendica\Protocol\OStatus; use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; -use Friendica\Util\XML; +use Friendica\Util\Network; use Friendica\Util\Security; use Friendica\Util\Strings; -use Friendica\Util\Network; +use Friendica\Util\XML; use Text_LanguageDetect; class Item extends BaseObject @@ -82,7 +82,7 @@ class Item extends BaseObject 'contact-id', 'type', 'wall', 'gravity', 'extid', 'icid', 'iaid', 'psid', 'created', 'edited', 'commented', 'received', 'changed', 'verb', 'postopts', 'plink', 'resource-id', 'event-id', 'tag', 'attach', 'inform', - 'file', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type', + 'file', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'item_id', 'post-type', 'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark', 'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global', 'network', 'title', 'content-warning', 'body', 'location', 'coord', 'app', From 766a10b3b61f8a7991c52be3c49d31680d330367 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 29 May 2019 19:57:45 +0200 Subject: [PATCH 5/9] Adding `author-network` to ITEM::ITEM_FIELDLIST see https://github.com/friendica/friendica/issues/6918#issuecomment-493515358 --- src/Model/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 865aa4ffc7..bd9cca0c92 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -87,7 +87,7 @@ class Item extends BaseObject 'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global', 'network', 'title', 'content-warning', 'body', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object-type', 'object', 'target-type', 'target', - 'author-id', 'author-link', 'author-name', 'author-avatar', + 'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', 'owner-id', 'owner-link', 'owner-name', 'owner-avatar']; // Never reorder or remove entries from this list. Just add new ones at the end, if needed. From 7334be803db6c02ca8da77ab9bf0c4e1fbf48c4c Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 29 May 2019 21:40:21 +0200 Subject: [PATCH 6/9] Bugfix - `item_id` --- mod/photos.php | 4 ++-- src/Model/Item.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mod/photos.php b/mod/photos.php index b18c06e2a3..0524845b15 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1504,7 +1504,7 @@ function photos_content(App $a) '$title' => $title_e, '$body' => $body_e, '$ago' => Temporal::getRelativeDate($item['created']), - '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''), + '$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''), '$drop' => $drop, '$comment' => $comment ]); @@ -1513,7 +1513,7 @@ function photos_content(App $a) $comments .= Renderer::replaceMacros($cmnt_tpl, [ '$return_path' => '', '$jsreload' => $return_path, - '$id' => $item['item_id'], + '$id' => $item['id'], '$parent' => $item['parent'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], diff --git a/src/Model/Item.php b/src/Model/Item.php index bd9cca0c92..cf4f3805af 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -82,12 +82,12 @@ class Item extends BaseObject 'contact-id', 'type', 'wall', 'gravity', 'extid', 'icid', 'iaid', 'psid', 'created', 'edited', 'commented', 'received', 'changed', 'verb', 'postopts', 'plink', 'resource-id', 'event-id', 'tag', 'attach', 'inform', - 'file', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'item_id', 'post-type', + 'file', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type', 'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark', 'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global', 'network', 'title', 'content-warning', 'body', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object-type', 'object', 'target-type', 'target', - 'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', + 'author-id', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'owner-name', 'owner-avatar']; // Never reorder or remove entries from this list. Just add new ones at the end, if needed. From 694cd82d0e406997e8e46f7f2e08eb4505faee3f Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Wed, 29 May 2019 21:48:03 +0200 Subject: [PATCH 7/9] Bugfix - `author-network` (adding to unset list during insert) --- src/Model/Item.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index cf4f3805af..8ae412cd0a 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -87,7 +87,7 @@ class Item extends BaseObject 'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global', 'network', 'title', 'content-warning', 'body', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object-type', 'object', 'target-type', 'target', - 'author-id', 'author-link', 'author-name', 'author-avatar', + 'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network', 'owner-id', 'owner-link', 'owner-name', 'owner-avatar']; // Never reorder or remove entries from this list. Just add new ones at the end, if needed. @@ -1721,6 +1721,7 @@ class Item extends BaseObject unset($item['author-link']); unset($item['author-name']); unset($item['author-avatar']); + unset($item['author-network']); unset($item['owner-link']); unset($item['owner-name']); From e4a63bc219274a128ea4d6fe0a61456e8e01d183 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Thu, 30 May 2019 10:18:52 +0200 Subject: [PATCH 8/9] Replace $_SESSION with Session::get() --- mod/redir.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mod/redir.php b/mod/redir.php index 931e07c770..0e93a63fc2 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -3,6 +3,7 @@ use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\Logger; +use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\Model\Contact; @@ -70,10 +71,9 @@ function redir_init(App $a) { && is_array($_SESSION['remote'])) { foreach ($_SESSION['remote'] as $v) { - if (!empty($v['uid']) && !empty($_SESSION['visitor_visiting']) && - !empty($v['cid']) && !empty($_SESSION['visitor_id']) && - $v['uid'] == $_SESSION['visitor_visiting'] && - $v['cid'] == $_SESSION['visitor_id']) { + if (!empty($v['uid']) && !empty($v['cid']) && + $v['uid'] === Session::get('visitor_visiting') && + $v['cid'] === Session::get('visitor_id')) { // Remote user is already authenticated. $target_url = defaults($url, $contact_url); Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG); From aa33a79e1349e37a042137ef6cc0667a2eea2c6c Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Thu, 30 May 2019 13:38:00 +0200 Subject: [PATCH 9/9] normal comparison --- mod/redir.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/redir.php b/mod/redir.php index 0e93a63fc2..233ec9b007 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -72,8 +72,8 @@ function redir_init(App $a) { { foreach ($_SESSION['remote'] as $v) { if (!empty($v['uid']) && !empty($v['cid']) && - $v['uid'] === Session::get('visitor_visiting') && - $v['cid'] === Session::get('visitor_id')) { + $v['uid'] == Session::get('visitor_visiting') && + $v['cid'] == Session::get('visitor_id')) { // Remote user is already authenticated. $target_url = defaults($url, $contact_url); Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG);