X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fredir.php;h=b2f76738bee74f020673e9a2a4bd69db960e83bd;hb=b79bb0d2cb3e6da43d7e6296f5afa29987be88e4;hp=cb1ca20e0e0f8d2c9bef12f53fbd90882fdf4178;hpb=1ca804b638d50aab9812c18d05fa51a0882c4fc9;p=friendica.git diff --git a/mod/redir.php b/mod/redir.php index cb1ca20e0e..b2f76738be 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -27,7 +27,6 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Profile; -use Friendica\Util\Network; use Friendica\Util\Strings; function redir_init(App $a) { @@ -48,7 +47,7 @@ function redir_init(App $a) { redir_magic($a, $cid, $url); if (empty($cid)) { - throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Contact not found.')); + throw new \Friendica\Network\HTTPException\BadRequestException(DI::l10n()->t('Bad Request.')); } $fields = ['id', 'uid', 'nurl', 'url', 'addr', 'name', 'network', 'poll', 'issued-id', 'dfrn-id', 'duplex', 'pending']; @@ -125,13 +124,10 @@ function redir_init(App $a) { System::externalRedirect($contact['poll'] . '?dfrn_id=' . $dfrn_id . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet); - - redir_check_url($contact_url, $url); - $url = $url ?: $contact_url; } if (empty($url)) { - throw new \Friendica\Network\HTTPException\NotFoundException(DI::l10n()->t('Contact not found.')); + throw new \Friendica\Network\HTTPException\BadRequestException(DI::l10n()->t('Bad Request.')); } // If we don't have a connected contact, redirect with @@ -174,7 +170,7 @@ function redir_magic($a, $cid, $url) } // Test for magic auth on the target system - $serverret = Network::curl($basepath . '/magic'); + $serverret = DI::httpRequest()->get($basepath . '/magic'); if ($serverret->isSuccess()) { $separator = strpos($target_url, '?') ? '&' : '?'; $target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url); @@ -193,6 +189,10 @@ function redir_check_url(string $contact_url, string $url) } $url_host = parse_url($url, PHP_URL_HOST); + if (empty($url_host)) { + $url_host = parse_url(DI::baseUrl(), PHP_URL_HOST); + } + $contact_url_host = parse_url($contact_url, PHP_URL_HOST); if ($url_host == $contact_url_host) { @@ -201,4 +201,4 @@ function redir_check_url(string $contact_url, string $url) Logger::error('URL check host mismatch', ['contact' => $contact_url, 'url' => $url]); throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Access denied.')); -} \ No newline at end of file +}