XML-RPC: Return error message if attachment ID is incorrect.

Throw an error for incorrect attachment IDs when requesting a media object to ensure return signature is correct and doesn't include incorrectly typed values within the object.

Props zieladam, peterwilsoncc, whyisjake.
See #49905.

Built from https://develop.svn.wordpress.org/branches/5.5@49376


git-svn-id: http://core.svn.wordpress.org/branches/5.5@49135 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2020-10-29 17:00:03 +00:00
parent a428042e49
commit 107e7856e6
2 changed files with 2 additions and 2 deletions

View File

@ -4292,7 +4292,7 @@ class wp_xmlrpc_server extends IXR_Server {
do_action( 'xmlrpc_call', 'wp.getMediaItem' );
$attachment = get_post( $attachment_id );
if ( ! $attachment ) {
if ( ! $attachment || 'attachment' !== $attachment->post_type ) {
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5.2-alpha-49375';
$wp_version = '5.5.2-alpha-49376';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.