From fbc1cd25288ebf5e972aa1eabc38afcafcd6b46b Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 17 Sep 2020 10:36:33 +0000 Subject: [PATCH 1/4] Fixes empty feed preview data --- src/Protocol/Feed.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 560fe005e6..7ed94f9f14 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -533,6 +533,9 @@ class Feed $replace = true; } + $saved_body = $item["body"]; + $saved_title = $item["title"]; + if ($replace) { $item["body"] = trim($item["title"]); } @@ -549,9 +552,17 @@ class Feed } } + $data = PageInfo::queryUrl($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_denylist"] ?? ''); + + // Take the data that was provided by the feed if the query wasn't empty + if (($data['type'] == 'link') && empty($data['title']) && empty($data['text'])) { + $data['title'] = $saved_title; + $item["body"] = $saved_body; + } + // We always strip the title since it will be added in the page information $item["title"] = ""; - $item["body"] = $item["body"] . "\n" . PageInfo::getFooterFromUrl($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_denylist"] ?? ''); + $item["body"] = $item["body"] . "\n" . PageInfo::getFooterFromData($data, false); $taglist = $contact["fetch_further_information"] == 2 ? PageInfo::getTagsFromUrl($item["plink"], $preview, $contact["ffi_keyword_denylist"] ?? '') : []; $item["object-type"] = Activity\ObjectType::BOOKMARK; unset($item["attach"]); From 1bbad87ff082c6fc77dbbdeac2a824f02dd98757 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 17 Sep 2020 13:07:20 +0000 Subject: [PATCH 2/4] Remove the text if it is identical to the body --- src/Protocol/Feed.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 7ed94f9f14..f414a3ca8a 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -560,6 +560,13 @@ class Feed $item["body"] = $saved_body; } + $data_text = strip_tags(trim($data['text'] ?? '')); + $item_body = strip_tags(trim($item['body'] ?? '')); + + if (!empty($data['text']) && (($data_text == $item_body) || strstr($item_body, $data_text))) { + $data['text'] = ''; + } + // We always strip the title since it will be added in the page information $item["title"] = ""; $item["body"] = $item["body"] . "\n" . PageInfo::getFooterFromData($data, false); From 005defa6cde4a5375401d9027a1453740bb26caf Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 17 Sep 2020 15:08:01 +0200 Subject: [PATCH 3/4] Update src/Protocol/Feed.php Co-authored-by: Hypolite Petovan --- src/Protocol/Feed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index f414a3ca8a..2873f44e12 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -554,7 +554,7 @@ class Feed $data = PageInfo::queryUrl($item["plink"], false, $preview, ($contact["fetch_further_information"] == 2), $contact["ffi_keyword_denylist"] ?? ''); - // Take the data that was provided by the feed if the query wasn't empty + // Take the data that was provided by the feed if the query is empty if (($data['type'] == 'link') && empty($data['title']) && empty($data['text'])) { $data['title'] = $saved_title; $item["body"] = $saved_body; From 032df50e9df72b0b37c2698c9e67aeb891f6ca88 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 17 Sep 2020 13:13:40 +0000 Subject: [PATCH 4/4] Simplify check --- src/Protocol/Feed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index f414a3ca8a..103f7a9f08 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -563,7 +563,7 @@ class Feed $data_text = strip_tags(trim($data['text'] ?? '')); $item_body = strip_tags(trim($item['body'] ?? '')); - if (!empty($data['text']) && (($data_text == $item_body) || strstr($item_body, $data_text))) { + if (($data_text == $item_body) || strstr($item_body, $data_text)) { $data['text'] = ''; }