]> git.mxchange.org Git - friendica-addons.git/commitdiff
[twitter] Improve probe_detect hook function
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 23 Nov 2021 22:51:12 +0000 (17:51 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 23 Nov 2021 22:51:12 +0000 (17:51 -0500)
- Prevent tweet URLs to be considered as contact URLs

twitter/twitter.php

index 8b7451b823028491b435a64058f105031d3c33cf..f31efe9766db5311db8112437257aabd1c8fe66d 100644 (file)
@@ -482,7 +482,7 @@ function twitter_post_local(App $a, array &$b)
 function twitter_probe_detect(App $a, array &$hookData)
 {
        // Don't overwrite an existing result
-       if ($hookData['result']) {
+       if (isset($hookData['result'])) {
                return;
        }
 
@@ -494,6 +494,13 @@ function twitter_probe_detect(App $a, array &$hookData)
        if (preg_match('=([^@]+)@(?:mobile\.)?twitter\.com$=i', $hookData['uri'], $matches)) {
                $nick = $matches[1];
        } elseif (preg_match('=^https?://(?:mobile\.)?twitter\.com/(.+)=i', $hookData['uri'], $matches)) {
+               if (strpos($matches[1], '/') !== false) {
+                       // Status case: https://twitter.com/<nick>/status/<status id>
+                       // Not a contact
+                       $hookData['result'] = false;
+                       return;
+               }
+
                $nick = $matches[1];
        } else {
                return;