2 Commity 8edd975b11 ... 119e2262d9

Autor SHA1 Správa Dátum
  Delilah Hoare 119e2262d9 Fix "Using $this when not in object context" 2 rokov pred
  Delilah Hoare 4670076956 Add HTTP(S) support to LRDDMethod_WebFinger 2 rokov pred

+ 1 - 1
plugins/LRDD/LRDDPlugin.php

@@ -82,7 +82,7 @@ class LRDDPlugin extends Plugin
         $all_ids = array_merge([$xrd->subject], $xrd->aliases);
 
         if (!in_array($uri, $all_ids)) {
-            $this->log(LOG_INFO, 'The original URI was not listed itself when doing discovery on it!');
+            common_log(LOG_INFO, 'The original URI was not listed itself when doing discovery on it!');
             return null;
         }
 

+ 17 - 8
plugins/LRDD/lib/lrddmethod/webfinger.php

@@ -31,15 +31,24 @@ class LRDDMethod_WebFinger extends LRDDMethod
      */
     public function discover($uri)
     {
-        $parts = explode('@', parse_url($uri, PHP_URL_PATH), 2);
+        $scheme = mb_strtolower(parse_url($uri, PHP_URL_SCHEME));
+        switch ($scheme) {
+        case 'acct':
+            // We can't use parse_url data for this, since the 'host'
+            // entry is only set if the scheme has '://' after it.
+            $parts = explode('@', parse_url($uri, PHP_URL_PATH), 2);
 
-        if (!Discovery::isAcct($uri) || count($parts) != 2) {
-            throw new Exception('Bad resource URI: ' . $uri);
-        }
-        [, $domain] = $parts;
-        if (!filter_var($domain, FILTER_VALIDATE_IP)
-            && !filter_var(gethostbyname($domain), FILTER_VALIDATE_IP)) {
-            throw new Exception('Bad resource host.');
+            if (!Discovery::isAcct($uri) || count($parts) != 2) {
+                throw new Exception('Bad resource URI: ' . $uri);
+            }
+            [, $domain] = $parts;
+            break;
+        case 'http':
+        case 'https':
+            $domain = mb_strtolower(parse_url($uri, PHP_URL_HOST));
+            break;
+        default:
+            throw new Exception('Unable to discover resource descriptor endpoint.');
         }
 
         $link = new XML_XRD_Element_Link(