Trim unicode spaces on imported name field.

This commit is contained in:
Mike Macgirvin 2022-06-17 16:22:17 -07:00
parent 7c4763e8ed
commit d2e0143ace
2 changed files with 5 additions and 1 deletions

View file

@ -2197,7 +2197,7 @@ class Activity
// store the actor record in XConfig
XConfig::Set($url, 'system', 'actor_record', $person_obj);
$name = escape_tags($person_obj['name']);
$name = unicode_trim(escape_tags($person_obj['name']));
if (!$name) {
$name = escape_tags($person_obj['preferredUsername']);
}

View file

@ -4165,3 +4165,7 @@ function wildmat($pattern, $string)
{
return preg_match("#^" . strtr(preg_quote($pattern, '#'), [ '\*' => '.*', '\?' => '.', '\[' => '[', '\]' => ']' ]) . "$#i", $string);
}
function unicode_trim($s) {
return preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $s);
}