Skip to content

Commit 4275202

Browse files
committed
Improve the capabilites checking in the XMLRPC code.
git-svn-id: https://develop.svn.wordpress.org/branches/3.0@16803 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5e575c3 commit 4275202

4 files changed

Lines changed: 53 additions & 20 deletions

File tree

readme.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<body>
99
<h1 id="logo">
1010
<a href="http://wordpress.org/"><img alt="WordPress" src="wp-admin/images/wordpress-logo.png" width="250" height="68" /></a>
11-
<br /> Version 3.0.2
11+
<br /> Version 3.0.3
1212
</h1>
1313
<p style="text-align: center">Semantic Personal Publishing Platform</p>
1414

wp-admin/includes/update-core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ function update_core($from, $to) {
274274
$mysql_version = $wpdb->db_version();
275275
$required_php_version = '4.3';
276276
$required_mysql_version = '4.1.2';
277-
$wp_version = '3.0.2';
277+
$wp_version = '3.0.3';
278278
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
279279
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
280280

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* @global string $wp_version
1010
*/
11-
$wp_version = '3.0.2';
11+
$wp_version = '3.0.3';
1212

1313
/**
1414
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

xmlrpc.php

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,9 +1156,12 @@ function wp_deleteComment($args) {
11561156

11571157
do_action('xmlrpc_call', 'wp.deleteComment');
11581158

1159-
if ( ! get_comment($comment_ID) )
1159+
if ( !$comment = get_comment( $comment_ID ) )
11601160
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
11611161

1162+
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
1163+
return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
1164+
11621165
return wp_delete_comment($comment_ID);
11631166
}
11641167

@@ -1184,11 +1187,14 @@ function wp_editComment($args) {
11841187

11851188
if ( !current_user_can( 'moderate_comments' ) )
11861189
return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
1190+
1191+
if ( !$comment = get_comment( $comment_ID ) )
1192+
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
11871193

1188-
do_action('xmlrpc_call', 'wp.editComment');
1194+
if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
1195+
return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this site.' ) );
11891196

1190-
if ( ! get_comment($comment_ID) )
1191-
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
1197+
do_action('xmlrpc_call', 'wp.editComment');
11921198

11931199
if ( isset($content_struct['status']) ) {
11941200
$statuses = get_comment_statuses();
@@ -1417,7 +1423,7 @@ function wp_getPageStatusList( $args ) {
14171423
if ( !$user = $this->login($username, $password) )
14181424
return $this->error;
14191425

1420-
if ( !current_user_can( 'edit_posts' ) )
1426+
if ( !current_user_can( 'edit_pages' ) )
14211427
return new IXR_Error( 403, __( 'You are not allowed access to details about this site.' ) );
14221428

14231429
do_action('xmlrpc_call', 'wp.getPageStatusList');
@@ -1957,7 +1963,7 @@ function blogger_deletePost($args) {
19571963
if ( !$actual_post || $actual_post['post_type'] != 'post' )
19581964
return new IXR_Error(404, __('Sorry, no such post.'));
19591965

1960-
if ( !current_user_can('edit_post', $post_ID) )
1966+
if ( !current_user_can('delete_post', $post_ID) )
19611967
return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.'));
19621968

19631969
$result = wp_delete_post($post_ID);
@@ -1987,30 +1993,42 @@ function mw_newPost($args) {
19871993
$username = $args[1];
19881994
$password = $args[2];
19891995
$content_struct = $args[3];
1990-
$publish = $args[4];
1996+
$publish = isset( $args[4] ) ? $args[4] : 0;
19911997

19921998
if ( !$user = $this->login($username, $password) )
19931999
return $this->error;
19942000

19952001
do_action('xmlrpc_call', 'metaWeblog.newPost');
1996-
1997-
$cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
1998-
$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
1999-
$post_type = 'post';
2002+
20002003
$page_template = '';
20012004
if ( !empty( $content_struct['post_type'] ) ) {
20022005
if ( $content_struct['post_type'] == 'page' ) {
2003-
$cap = ( $publish ) ? 'publish_pages' : 'edit_pages';
2006+
if ( $publish || 'publish' == $content_struct['page_status'])
2007+
$cap = 'publish_pages';
2008+
else
2009+
$cap = 'edit_pages';
20042010
$error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
20052011
$post_type = 'page';
20062012
if ( !empty( $content_struct['wp_page_template'] ) )
20072013
$page_template = $content_struct['wp_page_template'];
20082014
} elseif ( $content_struct['post_type'] == 'post' ) {
2009-
// This is the default, no changes needed
2015+
if ( $publish || 'publish' == $content_struct['post_status'])
2016+
$cap = 'publish_posts';
2017+
else
2018+
$cap = 'edit_posts';
2019+
$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
2020+
$post_type = 'post';
20102021
} else {
20112022
// No other post_type values are allowed here
20122023
return new IXR_Error( 401, __( 'Invalid post type.' ) );
20132024
}
2025+
} else {
2026+
if ( $publish || 'publish' == $content_struct['post_status'])
2027+
$cap = 'publish_posts';
2028+
else
2029+
$cap = 'edit_posts';
2030+
$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
2031+
$post_type = 'post';
20142032
}
20152033

20162034
if ( !current_user_can( $cap ) )
@@ -2275,17 +2293,32 @@ function mw_editPost($args) {
22752293
$page_template = '';
22762294
if ( !empty( $content_struct['post_type'] ) ) {
22772295
if ( $content_struct['post_type'] == 'page' ) {
2278-
$cap = ( $publish ) ? 'publish_pages' : 'edit_pages';
2296+
if ( $publish || 'publish' == $content_struct['page_status'] )
2297+
$cap = 'publish_pages';
2298+
else
2299+
$cap = 'edit_pages';
22792300
$error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
22802301
$post_type = 'page';
22812302
if ( !empty( $content_struct['wp_page_template'] ) )
22822303
$page_template = $content_struct['wp_page_template'];
22832304
} elseif ( $content_struct['post_type'] == 'post' ) {
2284-
// This is the default, no changes needed
2305+
if ( $publish || 'publish' == $content_struct['post_status'] )
2306+
$cap = 'publish_posts';
2307+
else
2308+
$cap = 'edit_posts';
2309+
$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
2310+
$post_type = 'post';
22852311
} else {
22862312
// No other post_type values are allowed here
22872313
return new IXR_Error( 401, __( 'Invalid post type.' ) );
22882314
}
2315+
} else {
2316+
if ( $publish || 'publish' == $content_struct['post_status'] )
2317+
$cap = 'publish_posts';
2318+
else
2319+
$cap = 'edit_posts';
2320+
$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
2321+
$post_type = 'post';
22892322
}
22902323

22912324
if ( !current_user_can( $cap ) )
@@ -3101,7 +3134,7 @@ function mt_publishPost($args) {
31013134

31023135
do_action('xmlrpc_call', 'mt.publishPost');
31033136

3104-
if ( !current_user_can('edit_post', $post_ID) )
3137+
if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) )
31053138
return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
31063139

31073140
$postdata = wp_get_single_post($post_ID,ARRAY_A);
@@ -3339,4 +3372,4 @@ function pingback_extensions_getPingbacks($args) {
33393372

33403373
$wp_xmlrpc_server = new wp_xmlrpc_server();
33413374
$wp_xmlrpc_server->serve_request();
3342-
?>
3375+
?>

0 commit comments

Comments
 (0)