]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Feed.php
Merge pull request #9146 from tobiasd/2020.09-CHANGELOG
[friendica.git] / src / Protocol / Feed.php
index 6b73e7af098020a85196e102176ebdc98533f9cd..67baf4b2aebf6412945579c7d3ca8e3cdf654bd2 100644 (file)
@@ -351,6 +351,8 @@ class Feed
 
                        $orig_plink = $item["plink"];
 
+                       $item["plink"] = DI::httpRequest()->finalUrl($item["plink"]);
+
                        $item["parent-uri"] = $item["uri"];
 
                        $item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);
@@ -492,6 +494,9 @@ class Feed
                        }
                        $item["body"] = HTML::toBBCode($body, $basepath);
 
+                       // Remove tracking pixels
+                       $item["body"] = preg_replace("/\[img=1x1\]([^\[\]]*)\[\/img\]/Usi", '', $item["body"]);
+
                        if (($item["body"] == '') && ($item["title"] != '')) {
                                $item["body"] = $item["title"];
                                $item["title"] = '';
@@ -531,6 +536,9 @@ class Feed
                                        $replace = true;
                                }
 
+                               $saved_body = $item["body"];
+                               $saved_title = $item["title"];
+
                                if ($replace) {
                                        $item["body"] = trim($item["title"]);
                                }
@@ -547,9 +555,24 @@ 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 is empty
+                               if (($data['type'] == 'link') && empty($data['title']) && empty($data['text'])) {
+                                       $data['title'] = $saved_title;
+                                       $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::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"]);