]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Don't check Link header if not set
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 15 Dec 2015 10:51:16 +0000 (11:51 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 15 Dec 2015 10:51:16 +0000 (11:51 +0100)
plugins/Linkback/LinkbackPlugin.php

index 0ab76f1d53512ee9688bdce5407a3d65225155fb..941e7c4c4b9241705c02dbddefb3e35586973bfe 100644 (file)
@@ -141,13 +141,16 @@ class LinkbackPlugin extends Plugin
     // Based on https://github.com/indieweb/mention-client-php
     // which is licensed Apache 2.0
     function getWebmention($result) {
-        // XXX: the fetcher only gives back one of each header, so this may fail on multiple Link headers
-        if(preg_match('~<((?:https?://)?[^>]+)>; rel="webmention"~', $result->headers['Link'], $match)) {
-            return $match[1];
-        } elseif(preg_match('~<((?:https?://)?[^>]+)>; rel="http://webmention.org/?"~', $result->headers['Link'], $match)) {
-            return $match[1];
+        if (isset($result->headers['Link'])) {
+            // XXX: the fetcher only gives back one of each header, so this may fail on multiple Link headers
+            if(preg_match('~<((?:https?://)?[^>]+)>; rel="webmention"~', $result->headers['Link'], $match)) {
+                return $match[1];
+            } elseif(preg_match('~<((?:https?://)?[^>]+)>; rel="http://webmention.org/?"~', $result->headers['Link'], $match)) {
+                return $match[1];
+            }
         }
 
+        // FIXME: Do proper DOM traversal
         if(preg_match('/<(?:link|a)[ ]+href="([^"]+)"[ ]+rel="[^" ]* ?webmention ?[^" ]*"[ ]*\/?>/i', $result->body, $match)
            || preg_match('/<(?:link|a)[ ]+rel="[^" ]* ?webmention ?[^" ]*"[ ]+href="([^"]+)"[ ]*\/?>/i', $result->body, $match)) {
             return $match[1];