mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update webfinger util, fail on invalid webfinger url
This commit is contained in:
parent
aad07e2c83
commit
2d11317ceb
2 changed files with 17 additions and 4 deletions
|
@ -63,7 +63,7 @@ class FederationController extends Controller
|
|||
}
|
||||
$webfinger = (new Webfinger($profile))->generate();
|
||||
|
||||
return response()->json($webfinger, 200, [], JSON_PRETTY_PRINT)
|
||||
return response()->json($webfinger, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)
|
||||
->header('Access-Control-Allow-Origin','*');
|
||||
}
|
||||
|
||||
|
|
|
@ -2,22 +2,35 @@
|
|||
|
||||
namespace App\Util\Lexer;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Nickname
|
||||
{
|
||||
public static function normalizeProfileUrl($url)
|
||||
{
|
||||
if (starts_with($url, 'acct:')) {
|
||||
if(!Str::of($url)->contains('@')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Str::startsWith($url, 'acct:')) {
|
||||
$url = str_replace('acct:', '', $url);
|
||||
}
|
||||
|
||||
if(starts_with($url, '@')) {
|
||||
if(Str::startsWith($url, '@')) {
|
||||
$url = substr($url, 1);
|
||||
|
||||
if(!Str::of($url)->contains('@')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$parts = explode('@', $url);
|
||||
$username = $parts[0];
|
||||
$domain = $parts[1];
|
||||
|
||||
return ['domain' => $domain, 'username' => $username];
|
||||
return [
|
||||
'domain' => $domain,
|
||||
'username' => $username
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue