From 6f2ba0c6193a229b3f371de2cae7b314927d4cbb Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 22 Mar 2016 19:58:59 -0700 Subject: rewrite the webfinger discovery logic --- mod/xrd.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'mod/xrd.php') diff --git a/mod/xrd.php b/mod/xrd.php index da4ab51a4..ed8e1eabe 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -7,8 +7,12 @@ function xrd_init(&$a) { $uri = urldecode(notags(trim($_GET['uri']))); logger('xrd: ' . $uri,LOGGER_DEBUG); - if(substr($uri,0,4) === 'http') + $resource = $uri; + + if(substr($uri,0,4) === 'http') { + $uri = str_replace('~','',$uri); $name = basename($uri); + } else { $local = str_replace('acct:', '', $uri); if(substr($local,0,2) == '//') @@ -35,9 +39,18 @@ function xrd_init(&$a) { header("Content-type: application/xrd+xml"); + $aliases = array('acct:' . $r[0]['channel_address'] . '@' . $a->get_hostname(), z_root() . '/channel/' . $r[0]['channel_address'], z_root() . '/~' . $r[0]['channel_address']); + + for($x = 0; $x < count($aliases); $x ++) { + if($aliases[$x] === $resource) + unset($aliases[$x]); + } + + $o = replace_macros(get_markup_template('xrd_person.tpl'), array( '$nick' => $r[0]['channel_address'], - '$accturi' => $uri, + '$accturi' => $resource, + '$aliases' => $aliases, '$profile_url' => $a->get_baseurl() . '/channel/' . $r[0]['channel_address'], '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['channel_address'], '$atom' => $a->get_baseurl() . '/feed/' . $r[0]['channel_address'], -- cgit v1.2.3