XML-RPC: Improve error messages for unprivileged users.

Add specific permission checks to avoid ambiguous failure messages.

This brings the changes in [49380] to the 5.5 branch.

Props zieladam, peterwilsoncc, xknown, whyisjake.

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


git-svn-id: http://core.svn.wordpress.org/branches/5.5@49148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2020-10-29 18:28:08 +00:00
parent d80104976c
commit 13bdf36937
2 changed files with 16 additions and 1 deletions

View File

@ -3875,6 +3875,21 @@ class wp_xmlrpc_server extends IXR_Server {
return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) ); return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) );
} }
if (
'publish' === get_post_status( $post_id ) &&
! current_user_can( 'edit_post', $post_id ) &&
post_password_required( $post_id )
) {
return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
}
if (
'private' === get_post_status( $post_id ) &&
! current_user_can( 'read_post', $post_id )
) {
return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
}
if ( empty( $content_struct['content'] ) ) { if ( empty( $content_struct['content'] ) ) {
return new IXR_Error( 403, __( 'Comment is required.' ) ); return new IXR_Error( 403, __( 'Comment is required.' ) );
} }

View File

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