]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/Probe.php
Merge remote-tracking branch 'upstream/develop' into issue-8546
[friendica.git] / src / Network / Probe.php
index ba58ff3d0437a469172bb7d2d4629cb10c9bceb4..1e6d8406a12697b58bc181708705ede0d4310fbe 100644 (file)
@@ -144,10 +144,10 @@ class Probe
 
                // Handles the case when the hostname contains the scheme
                if (!parse_url($host, PHP_URL_SCHEME)) {
-                       $ssl_url = "https://".$host."/.well-known/host-meta";
-                       $url = "http://".$host."/.well-known/host-meta";
+                       $ssl_url = "https://" . $host . "/.well-known/host-meta";
+                       $url = "http://" . $host . "/.well-known/host-meta";
                } else {
-                       $ssl_url = $host."/.well-known/host-meta";
+                       $ssl_url = $host . "/.well-known/host-meta";
                        $url = '';
                }
 
@@ -160,15 +160,19 @@ class Probe
                $ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
                if ($curlResult->isSuccess()) {
                        $xml = $curlResult->getBody();
-                       $xrd = XML::parseString($xml, false);
-                       $host_url = 'https://'.$host;
+                       $xrd = XML::parseString($xml, true);
+                       if (!empty($url)) {
+                               $host_url = 'https://' . $host;
+                       } else {
+                               $host_url = $host;
+                       }
                } elseif ($curlResult->isTimeout()) {
                        Logger::info('Probing timeout', ['url' => $ssl_url], Logger::DEBUG);
                        self::$istimeout = true;
                        return false;
                }
 
-               if (!is_object($xrd) && ! empty($url)) {
+               if (!is_object($xrd) && !empty($url)) {
                        $curlResult = Network::curl($url, false, ['timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml']);
                        $connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
                        if ($curlResult->isTimeout()) {
@@ -181,7 +185,7 @@ class Probe
                        }
 
                        $xml = $curlResult->getBody();
-                       $xrd = XML::parseString($xml, false);
+                       $xrd = XML::parseString($xml, true);
                        $host_url = 'http://'.$host;
                }
                if (!is_object($xrd)) {
@@ -932,7 +936,7 @@ class Probe
                }
 
                // If it is not JSON, maybe it is XML
-               $xrd = XML::parseString($data, false);
+               $xrd = XML::parseString($data, true);
                if (!is_object($xrd)) {
                        Logger::log("No webfinger data retrievable for ".$url, Logger::DEBUG);
                        return false;