diff options
author | Max Kostikov <max@kostikov.co> | 2019-08-10 11:15:48 +0200 |
---|---|---|
committer | Max Kostikov <max@kostikov.co> | 2019-08-10 11:15:48 +0200 |
commit | 0ce1a200f70c831aee2d2af3329133ef654f6b77 (patch) | |
tree | e9eb4cf4437ae7f3b70ef9a3409283f809327f6e | |
parent | 38f7d9ad371380763c129b66b44a227cc7035e1e (diff) | |
download | volse-hubzilla-0ce1a200f70c831aee2d2af3329133ef654f6b77.tar.gz volse-hubzilla-0ce1a200f70c831aee2d2af3329133ef654f6b77.tar.bz2 volse-hubzilla-0ce1a200f70c831aee2d2af3329133ef654f6b77.zip |
Improve plink to share tag detection
-rw-r--r-- | Zotlabs/Module/Linkinfo.php | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php index 7d6ff4043..fcf8a6aa1 100644 --- a/Zotlabs/Module/Linkinfo.php +++ b/Zotlabs/Module/Linkinfo.php @@ -46,18 +46,20 @@ class Linkinfo extends \Zotlabs\Web\Controller { logger('linkinfo: ' . $url); - // Replace plink URL with 'share' tag if possible - if (preg_match("/mid=b64\.(\w+)(&.+)?$/", $url, $mid)) { - - $r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d LIMIT 1", - dbesc(base64url_decode($mid[1])), - intval(local_channel()) - ); - if ($r) { - echo "[share=" . $r[0]['id'] . "][/share]"; - killme(); - } - } + // Replace plink URL with 'share' tag if possible + preg_match("/(mid=b64\.|display\/|posts\/)([\w\-]+)(&.+)?$/", $url, $mid); + + if (!empty($mid) && $mid[1] == 'mid=b64.') + $mid[2] = base64_decode($mid[2]); + + $r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d LIMIT 1", + dbesc((empty($mid) ? $url : $mid[2])), + intval(local_channel()) + ); + if ($r) { + echo "[share=" . $r[0]['id'] . "][/share]"; + killme(); + } $result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true)); if($result['success']) { |