From 42c06506ce213745e0bf5699b7e22976e20efc37 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 24 Feb 2019 13:36:37 -0500 Subject: [PATCH 1/4] Stop appending entry when parent is missing in OStatus - Addresses https://github.com/friendica/friendica/issues/6338#issuecomment-455785854 --- src/Protocol/OStatus.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 38105e452..dec5c4c80 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1763,20 +1763,17 @@ class OStatus $verb = NAMESPACE_ACTIVITY_SCHEMA."favorite"; self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false); - $as_object = $doc->createElement("activity:object"); - $parent = Item::selectFirst([], ['uri' => $item["thr-parent"], 'uid' => $item["uid"]]); + if (DBA::isResult($parent)) { + $as_object = $doc->createElement("activity:object"); - if (!$parent) { - $parent = []; + XML::addElement($doc, $as_object, "activity:object-type", self::constructObjecttype($parent)); + + self::entryContent($doc, $as_object, $parent, $owner, "New entry"); + + $entry->appendChild($as_object); } - XML::addElement($doc, $as_object, "activity:object-type", self::constructObjecttype($parent)); - - self::entryContent($doc, $as_object, $parent, $owner, "New entry"); - - $entry->appendChild($as_object); - self::entryFooter($doc, $entry, $item, $owner); return $entry; From 088885070286ccf9f58e97efdd9fba1861a39f17 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 24 Feb 2019 13:40:04 -0500 Subject: [PATCH 2/4] Fix missing avatar key in DFRN - Addresses https://github.com/friendica/friendica/issues/6338#issuecomment-456839092 --- src/Protocol/DFRN.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 39d982bb9..544e77fa8 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -1596,6 +1596,7 @@ class DFRN if (empty($author['avatar'])) { Logger::log('Empty author: ' . $xml); + $author['avatar'] = ''; } if (DBA::isResult($contact_old) && !$onlyfetch) { From e66768a0588e8ade3f72b76e59ac92ad2c9ac3bd Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 24 Feb 2019 14:00:40 -0500 Subject: [PATCH 3/4] Add empty entry author if contact query fails in DFRN - Addresses https://github.com/friendica/friendica/issues/6338#issuecomment-462722599 --- src/Protocol/DFRN.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 544e77fa8..e30f02756 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -763,31 +763,33 @@ class DFRN */ private static function addEntryAuthor(DOMDocument $doc, $element, $contact_url, $item) { - $contact = Contact::getDetailsByURL($contact_url, $item["uid"]); - $author = $doc->createElement($element); - XML::addElement($doc, $author, "name", $contact["name"]); - XML::addElement($doc, $author, "uri", $contact["url"]); - XML::addElement($doc, $author, "dfrn:handle", $contact["addr"]); - /// @Todo - /// - Check real image type and image size - /// - Check which of these boths elements we should use - $attributes = [ + $contact = Contact::getDetailsByURL($contact_url, $item["uid"]); + if (!empty($contact)) { + XML::addElement($doc, $author, "name", $contact["name"]); + XML::addElement($doc, $author, "uri", $contact["url"]); + XML::addElement($doc, $author, "dfrn:handle", $contact["addr"]); + + /// @Todo + /// - Check real image type and image size + /// - Check which of these boths elements we should use + $attributes = [ "rel" => "photo", "type" => "image/jpeg", "media:width" => 80, "media:height" => 80, "href" => $contact["photo"]]; - XML::addElement($doc, $author, "link", "", $attributes); + XML::addElement($doc, $author, "link", "", $attributes); - $attributes = [ + $attributes = [ "rel" => "avatar", "type" => "image/jpeg", "media:width" => 80, "media:height" => 80, "href" => $contact["photo"]]; - XML::addElement($doc, $author, "link", "", $attributes); + XML::addElement($doc, $author, "link", "", $attributes); + } return $author; } From f95f6eced920a04e1dfa5bd0624279048104d6e5 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 24 Feb 2019 14:32:51 -0500 Subject: [PATCH 4/4] Add scheme input protection in frio/config.php - Addresses https://github.com/friendica/friendica/issues/6338#issuecomment-464912016 --- view/theme/frio/config.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index f73ef3ab0..dcf38d423 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -35,16 +35,16 @@ function theme_admin_post(App $a) } if (isset($_POST['frio-settings-submit'])) { - Config::set('frio', 'scheme', $_POST['frio_scheme']); - Config::set('frio', 'nav_bg', $_POST['frio_nav_bg']); - Config::set('frio', 'nav_icon_color', $_POST['frio_nav_icon_color']); - Config::set('frio', 'link_color', $_POST['frio_link_color']); - Config::set('frio', 'background_color', $_POST['frio_background_color']); - Config::set('frio', 'contentbg_transp', $_POST['frio_contentbg_transp']); - Config::set('frio', 'background_image', $_POST['frio_background_image']); - Config::set('frio', 'bg_image_option', $_POST['frio_bg_image_option']); - Config::set('frio', 'login_bg_image', $_POST['frio_login_bg_image']); - Config::set('frio', 'login_bg_color', $_POST['frio_login_bg_color']); + Config::set('frio', 'scheme', defaults($_POST, 'frio_scheme', '')); + Config::set('frio', 'nav_bg', defaults($_POST, 'frio_nav_bg', '')); + Config::set('frio', 'nav_icon_color', defaults($_POST, 'frio_nav_icon_color', '')); + Config::set('frio', 'link_color', defaults($_POST, 'frio_link_color', '')); + Config::set('frio', 'background_color', defaults($_POST, 'frio_background_color', '')); + Config::set('frio', 'contentbg_transp', defaults($_POST, 'frio_contentbg_transp', '')); + Config::set('frio', 'background_image', defaults($_POST, 'frio_background_image', '')); + Config::set('frio', 'bg_image_option', defaults($_POST, 'frio_bg_image_option', '')); + Config::set('frio', 'login_bg_image', defaults($_POST, 'frio_login_bg_image', '')); + Config::set('frio', 'login_bg_color', defaults($_POST, 'frio_login_bg_color', '')); Config::set('frio', 'css_modified', time()); } }