Skip to content

Commit

Permalink
XML-RPC: Return error message if attachment ID is incorrect.
Browse files Browse the repository at this point in the history
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.
Merges [49376] to trunk.
See #49905.

git-svn-id: https://develop.svn.wordpress.org/trunk@49385 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
desrosj committed Oct 29, 2020
1 parent 5bc2778 commit a6488f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-xmlrpc-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -4311,7 +4311,7 @@ public function wp_getMediaItem( $args ) {
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.' ) );
}

Expand Down

0 comments on commit a6488f3

Please sign in to comment.