check if $resource is set

This commit is contained in:
Matthias Pfefferle 2023-11-21 15:00:39 +01:00
parent 60148a3b65
commit d00e5a03c8

View file

@ -41,9 +41,14 @@ class Webfinger {
* @return string|WP_Error The URL or WP_Error * @return string|WP_Error The URL or WP_Error
*/ */
public static function resolve( $resource ) { public static function resolve( $resource ) {
if ( ! $resource ) {
return null;
}
if ( ! preg_match( '/^@?' . ACTIVITYPUB_USERNAME_REGEXP . '$/i', $resource, $m ) ) { if ( ! preg_match( '/^@?' . ACTIVITYPUB_USERNAME_REGEXP . '$/i', $resource, $m ) ) {
return null; return null;
} }
$transient_key = 'activitypub_resolve_' . ltrim( $resource, '@' ); $transient_key = 'activitypub_resolve_' . ltrim( $resource, '@' );
$link = \get_transient( $transient_key ); $link = \get_transient( $transient_key );