1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-25 01:05:36 +00:00

Update AP helpers, improve preferredUsername validation

This commit is contained in:
Daniel Supernault 2023-11-09 02:47:20 -07:00
parent ff272292ef
commit 21218c794b
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -760,6 +760,13 @@ class Helpers {
if(!isset($res['preferredUsername']) && !isset($res['nickname'])) {
return;
}
// skip invalid usernames
if(!ctype_alnum($res['preferredUsername'])) {
$tmpUsername = str_replace(['_', '.', '-'], '', $res['preferredUsername']);
if(!ctype_alnum($tmpUsername)) {
return;
}
}
$username = (string) Purify::clean($res['preferredUsername'] ?? $res['nickname']);
if(empty($username)) {
return;