mirror of
https://ghproxy.net/https://github.com/fairpm/fair-plugin.git
synced 2025-09-03 15:07:44 +08:00
Ensure the returned MetadataDocument
ID matches the DID in the request. (#192)
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
This commit is contained in:
parent
46bf451c18
commit
be82312aa9
1 changed files with 11 additions and 1 deletions
|
@ -122,7 +122,17 @@ function fetch_package_metadata( string $id ) {
|
|||
}
|
||||
$repo_url = $service->serviceEndpoint;
|
||||
|
||||
return fetch_metadata_doc( $repo_url );
|
||||
$metadata = fetch_metadata_doc( $repo_url );
|
||||
|
||||
if ( is_wp_error( $metadata ) ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
if ( $metadata->id !== $id ) {
|
||||
return new WP_Error( 'fair.packages.fetch_metadata.mismatch', __( 'Fetched metadata does not match the requested DID.', 'fair' ) );
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue