From fab0d9b919cdd301d9478c2a6b86b95eac0697b8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 28 Dec 2019 19:17:48 +0000 Subject: [PATCH] Don't create contacts for unknown networks / improved content fetching --- src/Model/Contact.php | 2 +- src/Network/Probe.php | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 6c0436eea2..1fd8426acd 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1514,7 +1514,7 @@ class Contact extends BaseObject $data = array_merge($data, $default); } - if (empty($data)) { + if (empty($data) || ($data['network'] == Protocol::PHANTOM)) { return 0; } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 02a755eec6..878198504d 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -119,12 +119,16 @@ class Probe $xml = $curlResult->getBody(); $xrd = XML::parseString($xml, false); $host_url = 'https://'.$host; + } elseif ($curlResult->isTimeout()) { + Logger::info('Probing timeout', ['url' => $ssl_url], Logger::DEBUG); + self::$istimeout = true; + return false; } if (!is_object($xrd)) { $curlResult = Network::curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']); if ($curlResult->isTimeout()) { - Logger::log("Probing timeout for " . $url, Logger::DEBUG); + Logger::info('Probing timeout', ['url' => $url], Logger::DEBUG); self::$istimeout = true; return false; } @@ -1520,8 +1524,13 @@ class Probe */ private static function pumpioProfileData($profile_link) { + $curlResult = Network::curl($profile_link); + if (!$curlResult->isSuccess()) { + return false; + } + $doc = new DOMDocument(); - if (!@$doc->loadHTMLFile($profile_link)) { + if (!@$doc->loadHTML($curlResult->getBody())) { return false; } @@ -1693,9 +1702,13 @@ class Probe */ private static function getFeedLink($url) { - $doc = new DOMDocument(); + $curlResult = Network::curl($url); + if (!$curlResult->isSuccess()) { + return false; + } - if (!@$doc->loadHTMLFile($url)) { + $doc = new DOMDocument(); + if (!@$doc->loadHTML($curlResult->getBody())) { return false; }