]> git.mxchange.org Git - friendica.git/commitdiff
Feeds: Check the content type before fetching feeds
authorMichael <heluecht@pirati.ca>
Mon, 2 Sep 2024 06:14:59 +0000 (06:14 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 6 Sep 2024 08:21:23 +0000 (08:21 +0000)
src/Network/Probe.php
src/Worker/OnePoll.php

index e290553a701235686513782309540f93c50fb62e..21a190c7df47a1492d1cda245d6addb0ac861233 100644 (file)
@@ -1715,9 +1715,11 @@ class Probe
                }
 
                $feed = $curlResult->getBodyString();
-               $feed_data = Feed::import($feed);
+               if (strpos($curlResult->getContentType(), 'xml') !== false) {
+                       $feed_data = Feed::import($feed);
+               }
 
-               if (!$feed_data) {
+               if (empty($feed_data)) {
                        if (!$probe) {
                                return [];
                        }
index a305f85d5e499d3e29eff6ebadcf408345bbfa7f..bde45e39166c62449612034dcd2f725ffdda58c3 100644 (file)
@@ -188,6 +188,11 @@ class OnePoll
                        return false;
                }
 
+               if (strpos($curlResult->getContentType(), 'xml') !== false) {
+                       Logger::notice('Unexpected content type.', ['id' => $contact['id'], 'url' => $contact['poll'], 'content-type' => $curlResult->getContentType()]);
+                       return false;
+               }
+
                if (!strstr($xml, '<')) {
                        Logger::notice('response did not contain XML.', ['id' => $contact['id'], 'url' => $contact['poll']]);
                        return false;