Change all core API to expect unslashed rather than slashed arguments.

The exceptions to this are update_post_meta() and add_post_meta() which are often used by plugins in POST handlers and will continue accepting slashed data for now.

Introduce wp_upate_post_meta() and wp_add_post_meta() as unslashed alternatives to update_post_meta() and add_post_meta(). These functions could become methods in WP_Post so don't use them too heavily yet.

Remove all escape() calls from wp_xmlrpc_server. Now that core expects unslashed data this is no longer needed.

Remove addslashes(), addslashes_gpc(), add_magic_quotes() calls on data being prepared for handoff to core functions that until now expected slashed data. Adding slashes in no longer necessary.

Introduce wp_unslash() and use to it remove slashes from GPCS data before using it in core API. Almost every instance of stripslashes() in core should now be wp_unslash(). In the future (a release or three) when GPCS is no longer slashed, wp_unslash() will stop stripping slashes and simply return what is passed. At this point wp_unslash() calls can be removed from core.

Introduce wp_slash() for slashing GPCS data. This will also turn into a noop once GPCS is no longer slashed. wp_slash() should almost never be used. It is mainly of use in unit tests.

Plugins should use wp_unslash() on data being passed to core API.

Plugins should no longer slash data being passed to core. So when you get_post() and then wp_insert_post() the post data from get_post() no longer needs addslashes(). Most plugins were not bothering with this. They will magically start doing the right thing. Unfortunately, those few souls who did it properly will now have to avoid calling addslashes() for 3.6 and newer.

Use wp_kses_post() and wp_kses_data(), which expect unslashed data, instead of wp_filter_post_kses() and wp_filter_kses(), which expect slashed data. Filters are no longer passed slashed data.

Remove many no longer necessary calls to $wpdb->escape() and esc_sql().

In wp_get_referer() and wp_get_original_referer(), return unslashed data.

Remove old stripslashes() calls from WP_Widget::update() handlers. These haven't been necessary since WP_Widget.

Switch several queries over to prepare().

Expect something to break.

Props alexkingorg
see #21767


git-svn-id: https://develop.svn.wordpress.org/trunk@23416 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2013-02-14 22:51:06 +00:00
parent 4ca366a0d1
commit a6c8efadb9
86 changed files with 531 additions and 651 deletions
+1 -1
View File
@@ -310,7 +310,7 @@ final class WP_Customize_Manager {
public function post_value( $setting ) {
if ( ! isset( $this->_post_values ) ) {
if ( isset( $_POST['customized'] ) )
$this->_post_values = json_decode( stripslashes( $_POST['customized'] ), true );
$this->_post_values = json_decode( wp_unslash( $_POST['customized'] ), true );
else
$this->_post_values = false;
}
+1 -1
View File
@@ -144,7 +144,7 @@ class WP_Customize_Setting {
* @return mixed Null if an input isn't valid, otherwise the sanitized value.
*/
public function sanitize( $value ) {
$value = stripslashes_deep( $value );
$value = wp_unslash( $value );
return apply_filters( "customize_sanitize_{$this->id}", $value, $this );
}
+26 -179
View File
@@ -280,17 +280,15 @@ class wp_xmlrpc_server extends IXR_Server {
$meta['id'] = (int) $meta['id'];
$pmeta = get_metadata_by_mid( 'post', $meta['id'] );
if ( isset($meta['key']) ) {
$meta['key'] = stripslashes( $meta['key'] );
if ( $meta['key'] != $pmeta->meta_key )
continue;
$meta['value'] = stripslashes_deep( $meta['value'] );
if ( current_user_can( 'edit_post_meta', $post_id, $meta['key'] ) )
update_metadata_by_mid( 'post', $meta['id'], $meta['value'] );
} elseif ( current_user_can( 'delete_post_meta', $post_id, $pmeta->meta_key ) ) {
delete_metadata_by_mid( 'post', $meta['id'] );
}
} elseif ( current_user_can( 'add_post_meta', $post_id, stripslashes( $meta['key'] ) ) ) {
add_post_meta( $post_id, $meta['key'], $meta['value'] );
} elseif ( current_user_can( 'add_post_meta', $post_id, $meta['key'] ) ) {
wp_add_post_meta( $post_id, $meta['key'], $meta['value'] );
}
}
}
@@ -462,8 +460,6 @@ class wp_xmlrpc_server extends IXR_Server {
return $this->blogger_getUsersBlogs( $args );
}
$this->escape( $args );
$username = $args[0];
$password = $args[1];
@@ -955,8 +951,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1239,8 +1233,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 5 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1274,7 +1266,6 @@ class wp_xmlrpc_server extends IXR_Server {
else
$post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] );
$this->escape( $post );
$merged_content_struct = array_merge( $post, $content_struct );
$retval = $this->_insert_post( $user, $merged_content_struct );
@@ -1301,8 +1292,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1377,8 +1366,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1434,8 +1421,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1529,8 +1514,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1616,8 +1599,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 5 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1708,8 +1689,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 5 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1775,8 +1754,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 5 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1828,8 +1805,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1903,8 +1878,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -1947,8 +1920,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2016,8 +1987,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2069,8 +2038,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2137,8 +2104,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2184,8 +2149,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2249,8 +2212,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getPage($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$page_id = (int) $args[1];
$username = $args[2];
@@ -2292,8 +2253,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getPages($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2336,9 +2295,8 @@ class wp_xmlrpc_server extends IXR_Server {
* @return unknown
*/
function wp_newPage($args) {
// Items not escaped here will be escaped in newPost.
$username = $this->escape($args[1]);
$password = $this->escape($args[2]);
$username = $args[1];
$password = $args[2];
$page = $args[3];
$publish = $args[4];
@@ -2363,8 +2321,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return bool True, if success.
*/
function wp_deletePage($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2404,11 +2360,10 @@ class wp_xmlrpc_server extends IXR_Server {
* @return unknown
*/
function wp_editPage($args) {
// Items not escaped here will be escaped in editPost.
$blog_id = (int) $args[0];
$page_id = (int) $this->escape($args[1]);
$username = $this->escape($args[2]);
$password = $this->escape($args[3]);
$page_id = (int) $args[1];
$username = $args[2];
$password = $args[3];
$content = $args[4];
$publish = $args[5];
@@ -2453,8 +2408,6 @@ class wp_xmlrpc_server extends IXR_Server {
function wp_getPageList($args) {
global $wpdb;
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2503,9 +2456,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getAuthors($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2539,8 +2489,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getTags( $args ) {
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2580,8 +2528,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return int Category ID.
*/
function wp_newCategory($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2641,8 +2587,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return mixed See {@link wp_delete_term()} for return info.
*/
function wp_deleteCategory($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2673,8 +2617,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_suggestCategories($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2710,8 +2652,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getComment($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2751,8 +2691,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array. Contains a collection of comments. See {@link wp_xmlrpc_server::wp_getComment()} for a description of each item contents
*/
function wp_getComments($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2811,8 +2749,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return mixed {@link wp_delete_comment()}
*/
function wp_deleteComment($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2865,8 +2801,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return bool True, on success.
*/
function wp_editComment($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2942,8 +2876,6 @@ class wp_xmlrpc_server extends IXR_Server {
function wp_newComment($args) {
global $wpdb;
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -2978,9 +2910,9 @@ class wp_xmlrpc_server extends IXR_Server {
$comment['comment_post_ID'] = $post_id;
if ( $logged_in ) {
$comment['comment_author'] = $wpdb->escape( $user->display_name );
$comment['comment_author_email'] = $wpdb->escape( $user->user_email );
$comment['comment_author_url'] = $wpdb->escape( $user->user_url );
$comment['comment_author'] = $user->display_name;
$comment['comment_author_email'] = $user->user_email;
$comment['comment_author_url'] = $user->user_url;
$comment['user_ID'] = $user->ID;
} else {
$comment['comment_author'] = '';
@@ -3027,8 +2959,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getCommentStatusList($args) {
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3053,8 +2983,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getCommentCount( $args ) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3086,8 +3014,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getPostStatusList( $args ) {
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3112,8 +3038,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getPageStatusList( $args ) {
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3138,8 +3062,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getPageTemplates( $args ) {
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3165,8 +3087,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getOptions( $args ) {
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3215,8 +3135,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return unknown
*/
function wp_setOptions( $args ) {
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3264,8 +3182,6 @@ class wp_xmlrpc_server extends IXR_Server {
* - 'metadata'
*/
function wp_getMediaItem($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3309,8 +3225,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array. Contains a collection of media items. See {@link wp_xmlrpc_server::wp_getMediaItem()} for a description of each item contents
*/
function wp_getMediaLibrary($args) {
$this->escape($args);
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3351,8 +3265,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function wp_getPostFormats( $args ) {
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3411,8 +3323,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3457,8 +3367,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3511,8 +3419,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 4 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3577,8 +3483,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( ! $this->minimum_args( $args, 3 ) )
return $this->error;
$this->escape( $args );
$blog_id = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -3628,8 +3532,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( is_multisite() )
return $this->_multisite_getUsersBlogs($args);
$this->escape($args);
$username = $args[1];
$password = $args[2];
@@ -3691,9 +3593,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function blogger_getUserInfo($args) {
$this->escape($args);
$username = $args[1];
$password = $args[2];
@@ -3725,9 +3624,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function blogger_getPost($args) {
$this->escape($args);
$post_ID = (int) $args[1];
$username = $args[2];
$password = $args[3];
@@ -3746,9 +3642,9 @@ class wp_xmlrpc_server extends IXR_Server {
$categories = implode(',', wp_get_post_categories($post_ID));
$content = '<title>'.stripslashes($post_data['post_title']).'</title>';
$content = '<title>'.$post_data['post_title'].'</title>';
$content .= '<category>'.$categories.'</category>';
$content .= stripslashes($post_data['post_content']);
$content .= $post_data['post_content'];
$struct = array(
'userid' => (string) $post_data['post_author'],
@@ -3769,9 +3665,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function blogger_getRecentPosts($args) {
$this->escape($args);
// $args[0] = appkey - ignored
$blog_ID = (int) $args[1]; /* though we don't use it yet */
$username = $args[2];
@@ -3800,9 +3693,9 @@ class wp_xmlrpc_server extends IXR_Server {
$post_date = $this->_convert_date( $entry['post_date'] );
$categories = implode(',', wp_get_post_categories($entry['ID']));
$content = '<title>'.stripslashes($entry['post_title']).'</title>';
$content = '<title>'.$entry['post_title'].'</title>';
$content .= '<category>'.$categories.'</category>';
$content .= stripslashes($entry['post_content']);
$content .= $entry['post_content'];
$struct[] = array(
'userid' => (string) $entry['post_author'],
@@ -3850,9 +3743,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return int
*/
function blogger_newPost($args) {
$this->escape($args);
$blog_ID = (int) $args[1]; /* though we don't use it yet */
$username = $args[2];
$password = $args[3];
@@ -3904,9 +3794,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return bool true when done.
*/
function blogger_editPost($args) {
$this->escape($args);
$post_ID = (int) $args[1];
$username = $args[2];
$password = $args[3];
@@ -3923,8 +3810,6 @@ class wp_xmlrpc_server extends IXR_Server {
if ( !$actual_post || $actual_post['post_type'] != 'post' )
return new IXR_Error(404, __('Sorry, no such post.'));
$this->escape($actual_post);
if ( !current_user_can('edit_post', $post_ID) )
return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.'));
@@ -3960,8 +3845,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return bool True when post is deleted.
*/
function blogger_deletePost($args) {
$this->escape($args);
$post_ID = (int) $args[1];
$username = $args[2];
$password = $args[3];
@@ -4030,13 +3913,11 @@ class wp_xmlrpc_server extends IXR_Server {
* @return int
*/
function mw_newPost($args) {
$this->escape($args);
$blog_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
$blog_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
$content_struct = $args[3];
$publish = isset( $args[4] ) ? $args[4] : 0;
$publish = isset( $args[4] ) ? $args[4] : 0;
if ( !$user = $this->login($username, $password) )
return $this->error;
@@ -4316,7 +4197,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
}
if (!$found)
add_post_meta( $post_ID, 'enclosure', $encstring );
wp_add_post_meta( $post_ID, 'enclosure', $encstring );
}
}
@@ -4350,9 +4231,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return bool True on success.
*/
function mw_editPost($args) {
$this->escape($args);
$post_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -4391,7 +4269,6 @@ class wp_xmlrpc_server extends IXR_Server {
}
}
$this->escape($postdata);
extract($postdata, EXTR_SKIP);
// Let WordPress manage slug if none was provided.
@@ -4619,9 +4496,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function mw_getPost($args) {
$this->escape($args);
$post_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -4743,9 +4617,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function mw_getRecentPosts($args) {
$this->escape($args);
$blog_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -4858,9 +4729,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function mw_getCategories($args) {
$this->escape($args);
$blog_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -4907,10 +4775,10 @@ class wp_xmlrpc_server extends IXR_Server {
function mw_newMediaObject($args) {
global $wpdb;
$blog_ID = (int) $args[0];
$username = $wpdb->escape($args[1]);
$password = $wpdb->escape($args[2]);
$data = $args[3];
$blog_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
$data = $args[3];
$name = sanitize_file_name( $data['name'] );
$type = $data['type'];
@@ -4997,9 +4865,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function mt_getRecentPostTitles($args) {
$this->escape($args);
$blog_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -5057,9 +4922,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function mt_getCategoryList($args) {
$this->escape($args);
$blog_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -5095,9 +4957,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function mt_getPostCategories($args) {
$this->escape($args);
$post_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -5138,9 +4997,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return bool True on success.
*/
function mt_setPostCategories($args) {
$this->escape($args);
$post_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -5250,9 +5106,6 @@ class wp_xmlrpc_server extends IXR_Server {
* @return int
*/
function mt_publishPost($args) {
$this->escape($args);
$post_ID = (int) $args[0];
$username = $args[1];
$password = $args[2];
@@ -5274,7 +5127,6 @@ class wp_xmlrpc_server extends IXR_Server {
// retain old cats
$cats = wp_get_post_categories($post_ID);
$postdata['post_category'] = $cats;
$this->escape($postdata);
$result = wp_update_post($postdata);
@@ -5298,8 +5150,6 @@ class wp_xmlrpc_server extends IXR_Server {
do_action('xmlrpc_call', 'pingback.ping');
$this->escape($args);
$pagelinkedfrom = $args[0];
$pagelinkedto = $args[1];
@@ -5435,15 +5285,15 @@ class wp_xmlrpc_server extends IXR_Server {
$pagelinkedfrom = str_replace('&', '&amp;', $pagelinkedfrom);
$context = '[...] ' . esc_html( $excerpt ) . ' [...]';
$pagelinkedfrom = $wpdb->escape( $pagelinkedfrom );
$pagelinkedfrom = $pagelinkedfrom;
$comment_post_ID = (int) $post_ID;
$comment_author = $title;
$comment_author_email = '';
$this->escape($comment_author);
$comment_author;
$comment_author_url = $pagelinkedfrom;
$comment_content = $context;
$this->escape($comment_content);
$comment_content;
$comment_type = 'pingback';
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_content', 'comment_type');
@@ -5465,13 +5315,10 @@ class wp_xmlrpc_server extends IXR_Server {
* @return array
*/
function pingback_extensions_getPingbacks($args) {
global $wpdb;
do_action('xmlrpc_call', 'pingback.extensions.getPingbacks');
$this->escape($args);
$url = $args;
$post_ID = url_to_postid($url);
+6 -6
View File
@@ -142,15 +142,15 @@ class WP {
$this->did_permalink = true;
if ( isset($_SERVER['PATH_INFO']) )
$pathinfo = $_SERVER['PATH_INFO'];
$pathinfo = wp_unslash( $_SERVER['PATH_INFO'] );
else
$pathinfo = '';
$pathinfo_array = explode('?', $pathinfo);
$pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
$req_uri = $_SERVER['REQUEST_URI'];
$req_uri = wp_unslash( $_SERVER['REQUEST_URI'] );
$req_uri_array = explode('?', $req_uri);
$req_uri = $req_uri_array[0];
$self = $_SERVER['PHP_SELF'];
$self = wp_unslash( $_SERVER['PHP_SELF'] );
$home_path = parse_url(home_url());
if ( isset($home_path['path']) )
$home_path = $home_path['path'];
@@ -255,9 +255,9 @@ class WP {
if ( isset( $this->extra_query_vars[$wpvar] ) )
$this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
elseif ( isset( $_POST[$wpvar] ) )
$this->query_vars[$wpvar] = $_POST[$wpvar];
$this->query_vars[$wpvar] = wp_unslash( $_POST[$wpvar] );
elseif ( isset( $_GET[$wpvar] ) )
$this->query_vars[$wpvar] = $_GET[$wpvar];
$this->query_vars[$wpvar] = wp_unslash( $_GET[$wpvar] );
elseif ( isset( $perma_query_vars[$wpvar] ) )
$this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
@@ -356,7 +356,7 @@ class WP {
// Support for Conditional GET
if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
$client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
$client_etag = stripslashes( wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ) ); // Retain extra strip. See #2597
else $client_etag = false;
$client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
+11 -15
View File
@@ -633,22 +633,22 @@ function wp_set_comment_cookies($comment, $user) {
*/
function sanitize_comment_cookies() {
if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
$comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
$comment_author = stripslashes($comment_author);
$comment_author = wp_unslash( $_COOKIE['comment_author_'.COOKIEHASH] );
$comment_author = apply_filters('pre_comment_author_name', $comment_author);
$comment_author = esc_attr($comment_author);
$_COOKIE['comment_author_'.COOKIEHASH] = $comment_author;
}
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
$comment_author_email = stripslashes($comment_author_email);
$comment_author_email = wp_unslash( $_COOKIE['comment_author_email_'.COOKIEHASH] );
$comment_author_email = apply_filters('pre_comment_author_email', $comment_author_email);
$comment_author_email = esc_attr($comment_author_email);
$_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
}
if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
$comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
$comment_author_url = stripslashes($comment_author_url);
$comment_author_url = wp_unslash( $_COOKIE['comment_author_url_'.COOKIEHASH] );
$comment_author_url = apply_filters('pre_comment_author_url', $comment_author_url);
$_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
}
}
@@ -670,11 +670,10 @@ function wp_allow_comment($commentdata) {
extract($commentdata, EXTR_SKIP);
// Simple duplicate check
// expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
$dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_parent = '$comment_parent' AND comment_approved != 'trash' AND ( comment_author = '$comment_author' ";
$dupe = $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", $comment_post_ID, $comment_parent, $comment_author );
if ( $comment_author_email )
$dupe .= "OR comment_author_email = '$comment_author_email' ";
$dupe .= ") AND comment_content = '$comment_content' LIMIT 1";
$dupe .= $wpdb->prepare( "OR comment_author_email = %s ", $comment_author_email );
$dupe .= $wpdb->prepare( ") AND comment_content = %s LIMIT 1", $comment_content );
if ( $wpdb->get_var($dupe) ) {
do_action( 'comment_duplicate_trigger', $commentdata );
if ( defined('DOING_AJAX') )
@@ -1262,7 +1261,7 @@ function wp_get_current_commenter() {
*/
function wp_insert_comment($commentdata) {
global $wpdb;
extract(stripslashes_deep($commentdata), EXTR_SKIP);
extract($commentdata, EXTR_SKIP);
if ( ! isset($comment_author_IP) )
$comment_author_IP = '';
@@ -1491,9 +1490,6 @@ function wp_update_comment($commentarr) {
// First, get all of the original fields
$comment = get_comment($commentarr['comment_ID'], ARRAY_A);
// Escape data pulled from DB.
$comment = esc_sql($comment);
$old_status = $comment['comment_approved'];
// Merge old and new fields with new fields overwriting old ones.
@@ -1502,7 +1498,7 @@ function wp_update_comment($commentarr) {
$commentarr = wp_filter_comment( $commentarr );
// Now extract the merged array.
extract(stripslashes_deep($commentarr), EXTR_SKIP);
extract($commentarr, EXTR_SKIP);
$comment_content = apply_filters('comment_save_pre', $comment_content);
+1 -1
View File
@@ -230,7 +230,7 @@ function spawn_cron( $gmt_time = 0 ) {
set_transient( 'doing_cron', $doing_wp_cron );
ob_start();
wp_redirect( add_query_arg('doing_wp_cron', $doing_wp_cron, stripslashes($_SERVER['REQUEST_URI'])) );
wp_redirect( add_query_arg( 'doing_wp_cron', $doing_wp_cron, wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
echo ' ';
// flush any buffers and send the headers
+4 -4
View File
@@ -14,8 +14,8 @@
// Strip, trim, kses, special chars for string saves
foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname' ) as $filter ) {
add_filter( $filter, 'sanitize_text_field' );
add_filter( $filter, 'wp_filter_kses' );
add_filter( $filter, 'sanitize_text_field' );
add_filter( $filter, 'wp_kses_data' );
add_filter( $filter, '_wp_specialchars', 30 );
}
@@ -31,7 +31,7 @@ foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target',
// Kses only for textarea saves
foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
add_filter( $filter, 'wp_filter_kses' );
add_filter( $filter, 'wp_kses_data' );
}
// Kses only for textarea admin displays
@@ -46,7 +46,7 @@ if ( is_admin() ) {
foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) {
add_filter( $filter, 'trim' );
add_filter( $filter, 'sanitize_email' );
add_filter( $filter, 'wp_filter_kses' );
add_filter( $filter, 'wp_kses_data' );
}
// Email admin display
+4 -4
View File
@@ -412,7 +412,7 @@ class WP_Widget_Text extends WP_Widget {
if ( current_user_can('unfiltered_html') )
$instance['text'] = $new_instance['text'];
else
$instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
$instance['text'] = wp_kses_post( $new_instance['text'] );
$instance['filter'] = isset($new_instance['filter']);
return $instance;
}
@@ -1056,8 +1056,8 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
$instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['taxonomy'] = $new_instance['taxonomy'];
return $instance;
}
@@ -1118,7 +1118,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
}
function update( $new_instance, $old_instance ) {
$instance['title'] = strip_tags( stripslashes($new_instance['title']) );
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['nav_menu'] = (int) $new_instance['nav_menu'];
return $instance;
}
+1 -1
View File
@@ -2383,7 +2383,7 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) {
/** @todo Might need fix because usermeta data is assumed to be already escaped */
if ( is_string($meta_value) )
$meta_value = stripslashes($meta_value);
$meta_value = $meta_value;
$meta_value = maybe_serialize($meta_value);
if (empty($meta_value)) {
+1 -1
View File
@@ -488,7 +488,7 @@ function prep_atom_text_construct($data) {
*/
function self_link() {
$host = @parse_url(home_url());
echo esc_url( set_url_scheme( 'http://' . $host['host'] . stripslashes($_SERVER['REQUEST_URI']) ) );
echo esc_url( set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
}
/**
+50 -3
View File
@@ -1716,10 +1716,7 @@ function _split_str_by_whitespace( $string, $goal ) {
* @return string Converted content.
*/
function wp_rel_nofollow( $text ) {
// This is a pre save filter, so text is already escaped.
$text = stripslashes($text);
$text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text);
$text = esc_sql($text);
return $text;
}
@@ -3342,3 +3339,53 @@ function sanitize_trackback_urls( $to_ping ) {
$urls_to_ping = implode( "\n", $urls_to_ping );
return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping );
}
/**
* Conditionally add slashes to a string or array of strings. When GPCS
* slashing is turned on, slashes are added. When GPCS slashing is turned off,
* slashes are not added.
*
* This should be used when preparing data for core API that deal directly with GPCS data.
* Outside of unit tests, this should be rare. At a future date GPCS will no longer
* be slashed and this function will noop. Do not use it in situations where adding slashes
* is always required regardless of whether GPCS is slashed.
*
* @since 3.6.0
*
* @param string|array $value String or array of strings to slash.
* @return string|array Slashed $value
*/
function wp_slash( $value ) {
if ( is_array( $value ) ) {
foreach ( $value as $k => $v ) {
if ( is_array( $v ) ) {
$value[$k] = wp_slash( $v );
} else {
$value[$k] = addslashes( $v );
}
}
} else {
$value = addslashes( $value );
}
return $value;
}
/**
* Conditionally removes slashes from a string or array of strings. When GPCS
* slashing is turned on, slashes are stripped. When GPCS slashing is turned off,
* slashes are not stripped.
*
* This should be used for GPCS data before passing it along to core API. At a future
* date GPCS will no longer be slashed and this function will noop. Do not use it
* in situations where slash stripping is always required regardless of whether GPCS
* is slashed.
*
* @since 3.6.0
*
* @param string|array $value String or array of strings to unslash.
* @return string|array Unslashed $value
*/
function wp_unslash( $value ) {
return stripslashes_deep( $value );
}
+8 -8
View File
@@ -468,7 +468,7 @@ function do_enclose( $content, $post_ID ) {
}
if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
wp_add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
}
}
}
@@ -1256,9 +1256,9 @@ function wp_referer_field( $echo = true ) {
* @return string Original referer field.
*/
function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
$jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
$jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
$ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to;
$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( stripslashes( $ref ) ) . '" />';
$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />';
if ( $echo )
echo $orig_referer_field;
return $orig_referer_field;
@@ -1277,11 +1277,11 @@ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
function wp_get_referer() {
$ref = false;
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
$ref = $_REQUEST['_wp_http_referer'];
$ref = wp_unslash( $_REQUEST['_wp_http_referer'] );
else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
$ref = $_SERVER['HTTP_REFERER'];
$ref = wp_unslash( $_SERVER['HTTP_REFERER'] );
if ( $ref && $ref !== $_SERVER['REQUEST_URI'] )
if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) )
return $ref;
return false;
}
@@ -1297,7 +1297,7 @@ function wp_get_referer() {
*/
function wp_get_original_referer() {
if ( !empty( $_REQUEST['_wp_original_http_referer'] ) )
return $_REQUEST['_wp_original_http_referer'];
return wp_unslash( $_REQUEST['_wp_original_http_referer'] );
return false;
}
@@ -3879,4 +3879,4 @@ function wp_is_stream( $path ) {
*/
function wp_checkdate( $month, $day, $year, $source_date ) {
return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date );
}
}
+12 -12
View File
@@ -1326,18 +1326,18 @@ function wp_filter_nohtml_kses( $data ) {
*/
function kses_init_filters() {
// Normal filtering
add_filter('title_save_pre', 'wp_filter_kses');
add_filter('title_save_pre', 'wp_kses_data');
// Comment filtering
if ( current_user_can( 'unfiltered_html' ) )
add_filter( 'pre_comment_content', 'wp_filter_post_kses' );
add_filter( 'pre_comment_content', 'wp_kses_post' );
else
add_filter( 'pre_comment_content', 'wp_filter_kses' );
add_filter( 'pre_comment_content', 'wp_kses_data' );
// Post filtering
add_filter('content_save_pre', 'wp_filter_post_kses');
add_filter('excerpt_save_pre', 'wp_filter_post_kses');
add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
add_filter('content_save_pre', 'wp_kses_post');
add_filter('excerpt_save_pre', 'wp_kses_post');
add_filter('content_filtered_save_pre', 'wp_kses_post');
}
/**
@@ -1354,16 +1354,16 @@ function kses_init_filters() {
*/
function kses_remove_filters() {
// Normal filtering
remove_filter('title_save_pre', 'wp_filter_kses');
remove_filter('title_save_pre', 'wp_kses_data');
// Comment filtering
remove_filter( 'pre_comment_content', 'wp_filter_post_kses' );
remove_filter( 'pre_comment_content', 'wp_filter_kses' );
remove_filter( 'pre_comment_content', 'wp_kses_post' );
remove_filter( 'pre_comment_content', 'wp_kses_data' );
// Post filtering
remove_filter('content_save_pre', 'wp_filter_post_kses');
remove_filter('excerpt_save_pre', 'wp_filter_post_kses');
remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
remove_filter('content_save_pre', 'wp_kses_post');
remove_filter('excerpt_save_pre', 'wp_kses_post');
remove_filter('content_filtered_save_pre', 'wp_kses_post');
}
/**
+1 -1
View File
@@ -746,7 +746,7 @@ function get_search_link( $query = '' ) {
if ( empty($query) )
$search = get_search_query( false );
else
$search = stripslashes($query);
$search = $query;
$permastruct = $wp_rewrite->get_search_permastruct();
-9
View File
@@ -42,9 +42,6 @@ function add_metadata($meta_type, $object_id, $meta_key, $meta_value, $unique =
$column = esc_sql($meta_type . '_id');
// expected_slashed ($meta_key)
$meta_key = stripslashes($meta_key);
$meta_value = stripslashes_deep($meta_value);
$meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type );
$check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique );
@@ -113,10 +110,7 @@ function update_metadata($meta_type, $object_id, $meta_key, $meta_value, $prev_v
$column = esc_sql($meta_type . '_id');
$id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
// expected_slashed ($meta_key)
$meta_key = stripslashes($meta_key);
$passed_value = $meta_value;
$meta_value = stripslashes_deep($meta_value);
$meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type );
$check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
@@ -195,9 +189,6 @@ function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $d
$type_column = esc_sql($meta_type . '_id');
$id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
// expected_slashed ($meta_key)
$meta_key = stripslashes($meta_key);
$meta_value = stripslashes_deep($meta_value);
$check = apply_filters( "delete_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $delete_all );
if ( null !== $check )
+1 -1
View File
@@ -58,7 +58,7 @@ header( 'ETag: ' . $etag );
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' );
// Support for Conditional GET
$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
$client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false;
if( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = false;
+11 -17
View File
@@ -279,9 +279,6 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
* @return int The ID of the newly created blog
*/
function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
$domain = addslashes( $domain );
$weblog_title = addslashes( $weblog_title );
if ( empty($path) )
$path = '/';
@@ -582,7 +579,7 @@ function wpmu_validate_blog_signup($blogname, $blog_title, $user = '') {
$blogname = apply_filters( 'newblogname', $blogname );
$blog_title = stripslashes( $blog_title );
$blog_title = $blog_title;
if ( empty( $blog_title ) )
$errors->add('blog_title', __( 'Please enter a site title.' ) );
@@ -635,10 +632,7 @@ function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = ''
global $wpdb;
$key = substr( md5( time() . rand() . $domain ), 0, 16 );
$meta = serialize($meta);
$domain = $wpdb->escape($domain);
$path = $wpdb->escape($path);
$title = $wpdb->escape($title);
$meta = serialize( $meta );
$wpdb->insert( $wpdb->signups, array(
'domain' => $domain,
@@ -651,7 +645,7 @@ function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = ''
'meta' => $meta
) );
wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta);
wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta );
}
/**
@@ -841,8 +835,8 @@ function wpmu_activate_signup($key) {
}
$meta = maybe_unserialize($signup->meta);
$user_login = $wpdb->escape($signup->user_login);
$user_email = $wpdb->escape($signup->user_email);
$user_login = $signup->user_login;
$user_email = $signup->user_email;
$password = wp_generate_password( 12, false );
$user_id = username_exists($user_login);
@@ -1159,7 +1153,7 @@ function install_blog($blog_id, $blog_title = '') {
else
update_option( 'upload_path', get_blog_option( $current_site->blog_id, 'upload_path' ) );
update_option( 'blogname', stripslashes( $blog_title ) );
update_option( 'blogname', $blog_title );
update_option( 'admin_email', '' );
// remove all perms
@@ -1216,9 +1210,9 @@ function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta
if ( !apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta) )
return false;
$welcome_email = stripslashes( get_site_option( 'welcome_email' ) );
$welcome_email = get_site_option( 'welcome_email' );
if ( $welcome_email == false )
$welcome_email = stripslashes( __( 'Dear User,
$welcome_email = __( 'Dear User,
Your new SITE_NAME site has been successfully set up at:
BLOG_URL
@@ -1230,7 +1224,7 @@ Log in here: BLOG_URLwp-login.php
We hope you enjoy your new site. Thanks!
--The Team @ SITE_NAME' ) );
--The Team @ SITE_NAME' );
$url = get_blogaddress_by_id($blog_id);
$user = get_userdata( $user_id );
@@ -1254,7 +1248,7 @@ We hope you enjoy your new site. Thanks!
if ( empty( $current_site->site_name ) )
$current_site->site_name = 'WordPress';
$subject = apply_filters( 'update_welcome_subject', sprintf(__('New %1$s Site: %2$s'), $current_site->site_name, stripslashes( $title ) ) );
$subject = apply_filters( 'update_welcome_subject', sprintf(__('New %1$s Site: %2$s'), $current_site->site_name, $title ) );
wp_mail($user->user_email, $subject, $message, $message_headers);
return true;
}
@@ -1509,7 +1503,7 @@ function update_posts_count( $deprecated = '' ) {
function wpmu_log_new_registrations( $blog_id, $user_id ) {
global $wpdb;
$user = get_userdata( (int) $user_id );
$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '',$_SERVER['REMOTE_ADDR'] ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
$wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
}
/**
+9 -9
View File
@@ -369,20 +369,20 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
$menu_item_db_id = (int) $menu_item_db_id;
update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($args['menu-item-type']) );
update_post_meta( $menu_item_db_id, '_menu_item_menu_item_parent', strval( (int) $args['menu-item-parent-id'] ) );
update_post_meta( $menu_item_db_id, '_menu_item_object_id', strval( (int) $args['menu-item-object-id'] ) );
update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($args['menu-item-object']) );
update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($args['menu-item-target']) );
wp_update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($args['menu-item-type']) );
wp_update_post_meta( $menu_item_db_id, '_menu_item_menu_item_parent', strval( (int) $args['menu-item-parent-id'] ) );
wp_update_post_meta( $menu_item_db_id, '_menu_item_object_id', strval( (int) $args['menu-item-object-id'] ) );
wp_update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($args['menu-item-object']) );
wp_update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($args['menu-item-target']) );
$args['menu-item-classes'] = array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-classes'] ) );
$args['menu-item-xfn'] = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-xfn'] ) ) );
update_post_meta( $menu_item_db_id, '_menu_item_classes', $args['menu-item-classes'] );
update_post_meta( $menu_item_db_id, '_menu_item_xfn', $args['menu-item-xfn'] );
update_post_meta( $menu_item_db_id, '_menu_item_url', esc_url_raw($args['menu-item-url']) );
wp_update_post_meta( $menu_item_db_id, '_menu_item_classes', $args['menu-item-classes'] );
wp_update_post_meta( $menu_item_db_id, '_menu_item_xfn', $args['menu-item-xfn'] );
wp_update_post_meta( $menu_item_db_id, '_menu_item_url', esc_url_raw($args['menu-item-url']) );
if ( 0 == $menu_id )
update_post_meta( $menu_item_db_id, '_menu_item_orphaned', (string) time() );
wp_update_post_meta( $menu_item_db_id, '_menu_item_orphaned', (string) time() );
elseif ( get_post_meta( $menu_item_db_id, '_menu_item_orphaned' ) )
delete_post_meta( $menu_item_db_id, '_menu_item_orphaned' );
+3 -3
View File
@@ -782,7 +782,7 @@ function auth_redirect() {
// The cookie is no good so force login
nocache_headers();
$redirect = ( strpos( $_SERVER['REQUEST_URI'], '/options.php' ) && wp_get_referer() ) ? wp_get_referer() : set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$redirect = ( strpos( $_SERVER['REQUEST_URI'], '/options.php' ) && wp_get_referer() ) ? wp_get_referer() : set_url_scheme( 'http://' . wp_unslash( $_SERVER['HTTP_HOST'] ) . wp_unslash( $_SERVER['REQUEST_URI'] ) );
$login_url = wp_login_url($redirect, true);
@@ -1197,8 +1197,8 @@ if ( !function_exists('wp_new_user_notification') ) :
function wp_new_user_notification($user_id, $plaintext_pass = '') {
$user = get_userdata( $user_id );
$user_login = stripslashes($user->user_login);
$user_email = stripslashes($user->user_email);
$user_login = $user->user_login;
$user_email = $user->user_email;
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
// we want to reverse this for the plain text arena of emails.
+1 -1
View File
@@ -583,7 +583,7 @@ function post_password_required( $post = null ) {
$wp_hasher = new PasswordHash(8, true);
}
$hash = stripslashes( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
$hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
return ! $wp_hasher->CheckPassword( $post->post_password, $hash );
}
+73 -36
View File
@@ -1742,17 +1742,41 @@ function get_posts($args = null) {
* @link http://codex.wordpress.org/Function_Reference/add_post_meta
*
* @param int $post_id Post ID.
* @param string $meta_key Metadata name.
* @param mixed $meta_value Metadata value.
* @param string $meta_key Metadata name (expected slashed).
* @param mixed $meta_value Metadata value (expected slashed).
* @param bool $unique Optional, default is false. Whether the same key should not be added.
* @return bool False for failure. True for success.
*/
function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) {
function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
//_deprecated_function( __FUNCTION__, '3.6', 'wp_add_post_meta() (expects unslashed data)' );
// expected slashed
$meta_key = stripslashes( $meta_key );
$meta_value = stripslashes_deep( $meta_value );
return wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique );
}
/**
* Add meta data field to a post.
*
* Post meta data is called "Custom Fields" on the Administration Screen.
*
* @since 3.6.0
* @link http://codex.wordpress.org/Function_Reference/wp_add_post_meta
*
* @param int $post_id Post ID.
* @param string $meta_key Metadata name (clean, slashes already stripped).
* @param mixed $meta_value Metadata value (clean, slashes already stripped).
* @param bool $unique Optional, default is false. Whether the same key should not be added.
* @return bool False for failure. True for success.
*/
function wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
// make sure meta is added to the post, not a revision
if ( $the_post = wp_is_post_revision($post_id) )
if ( $the_post = wp_is_post_revision( $post_id ) )
$post_id = $the_post;
return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
return add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique );
}
/**
@@ -1809,17 +1833,45 @@ function get_post_meta($post_id, $key = '', $single = false) {
* @link http://codex.wordpress.org/Function_Reference/update_post_meta
*
* @param int $post_id Post ID.
* @param string $meta_key Metadata key.
* @param mixed $meta_value Metadata value.
* @param string $meta_key Metadata key (expected slashed).
* @param mixed $meta_value Metadata value (expected slashed).
* @param mixed $prev_value Optional. Previous value to check before removing.
* @return bool False on failure, true if success.
*/
function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
//_deprecated_function( __FUNCTION__, '3.6', 'wp_update_post_meta() (expects unslashed data)' );
// expected slashed
$meta_key = stripslashes( $meta_key );
$meta_value = stripslashes_deep( $meta_value );
return wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value );
}
/**
* Update post meta field based on post ID.
*
* Use the $prev_value parameter to differentiate between meta fields with the
* same key and post ID.
*
* If the meta field for the post does not exist, it will be added.
*
* @since 3.6.0
* @uses $wpdb
* @link http://codex.wordpress.org/Function_Reference/wp_update_post_meta
*
* @param int $post_id Post ID.
* @param string $meta_key Metadata key (clean, slashes already stripped).
* @param mixed $meta_value Metadata value (clean, slashes already stripped).
* @param mixed $prev_value Optional. Previous value to check before removing.
* @return bool False on failure, true if success.
*/
function wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
// make sure meta is added to the post, not a revision
if ( $the_post = wp_is_post_revision($post_id) )
if ( $the_post = wp_is_post_revision( $post_id ) )
$post_id = $the_post;
return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
return update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value );
}
/**
@@ -2406,8 +2458,8 @@ function wp_trash_post($post_id = 0) {
do_action('wp_trash_post', $post_id);
add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
add_post_meta($post_id,'_wp_trash_meta_time', time());
wp_add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
wp_add_post_meta($post_id,'_wp_trash_meta_time', time());
$post['post_status'] = 'trash';
wp_insert_post($post);
@@ -2483,7 +2535,7 @@ function wp_trash_post_comments($post = null) {
$statuses = array();
foreach ( $comments as $comment )
$statuses[$comment->comment_ID] = $comment->comment_approved;
add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
wp_add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
// Set status for all comments to post-trashed
$result = $wpdb->update($wpdb->comments, array('comment_approved' => 'post-trashed'), array('comment_post_ID' => $post_id));
@@ -2859,10 +2911,8 @@ function wp_insert_post($postarr, $wp_error = false) {
$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
// expected_slashed (everything!)
$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) );
$data = apply_filters('wp_insert_post_data', $data, $postarr);
$data = stripslashes_deep( $data );
$where = array( 'ID' => $post_ID );
if ( $update ) {
@@ -2875,7 +2925,7 @@ function wp_insert_post($postarr, $wp_error = false) {
}
} else {
if ( isset($post_mime_type) )
$data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update
$data['post_mime_type'] = $post_mime_type; // This isn't in the update
// If there is a suggested ID, use it if not already present
if ( !empty($import_id) ) {
$import_id = (int) $import_id;
@@ -2936,7 +2986,7 @@ function wp_insert_post($postarr, $wp_error = false) {
else
return 0;
}
update_post_meta($post_ID, '_wp_page_template', $page_template);
wp_update_post_meta($post_ID, '_wp_page_template', $page_template);
}
wp_transition_post_status($data['post_status'], $previous_status, $post);
@@ -2969,15 +3019,11 @@ function wp_update_post( $postarr = array(), $wp_error = false ) {
if ( is_object($postarr) ) {
// non-escaped post was passed
$postarr = get_object_vars($postarr);
$postarr = add_magic_quotes($postarr);
}
// First, get all of the original fields
$post = get_post($postarr['ID'], ARRAY_A);
// Escape data pulled from DB.
$post = add_magic_quotes($post);
// Passed post category list overwrites existing category list if not empty.
if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
&& 0 != count($postarr['post_category']) )
@@ -3392,7 +3438,7 @@ function trackback_url_list($tb_list, $post_id) {
$trackback_urls = explode(',', $tb_list);
foreach( (array) $trackback_urls as $tb_url) {
$tb_url = trim($tb_url);
trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
trackback($tb_url, $post_title, $excerpt, $post_id);
}
}
}
@@ -3735,9 +3781,6 @@ function get_pages($args = '') {
if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) {
$join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )";
// meta_key and meta_value might be slashed
$meta_key = stripslashes($meta_key);
$meta_value = stripslashes($meta_value);
if ( ! empty( $meta_key ) )
$where .= $wpdb->prepare(" AND $wpdb->postmeta.meta_key = %s", $meta_key);
if ( ! empty( $meta_value ) )
@@ -3962,7 +4005,6 @@ function wp_insert_attachment($object, $file = false, $parent = 0) {
else
$post_name = sanitize_title($post_name);
// expected_slashed ($post_name)
$post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
if ( empty($post_date) )
@@ -4005,9 +4047,7 @@ function wp_insert_attachment($object, $file = false, $parent = 0) {
if ( ! isset($pinged) )
$pinged = '';
// expected_slashed (everything!)
$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' ) );
$data = stripslashes_deep( $data );
if ( $update ) {
$wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) );
@@ -4052,7 +4092,7 @@ function wp_insert_attachment($object, $file = false, $parent = 0) {
clean_post_cache( $post_ID );
if ( ! empty( $context ) )
add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
wp_add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
if ( $update) {
do_action('edit_attachment', $post_ID);
@@ -4439,7 +4479,7 @@ function wp_check_for_changed_slugs($post_id, $post, $post_before) {
// if we haven't added this old slug before, add it now
if ( !empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) )
add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
wp_add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
// if the new slug was used previously, delete it from the list
if ( in_array($post->post_name, $old_slugs) )
@@ -4856,8 +4896,8 @@ function _publish_post_hook($post_id) {
return;
if ( get_option('default_pingback_flag') )
add_post_meta( $post_id, '_pingme', '1' );
add_post_meta( $post_id, '_encloseme', '1' );
wp_add_post_meta( $post_id, '_pingme', '1' );
wp_add_post_meta( $post_id, '_encloseme', '1' );
wp_schedule_single_event(time(), 'do_pings');
}
@@ -5097,7 +5137,6 @@ function _wp_put_post_revision( $post = null, $autosave = false ) {
return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) );
$post = _wp_post_revision_fields( $post, $autosave );
$post = add_magic_quotes($post); //since data is from db
$revision_id = wp_insert_post( $post );
if ( is_wp_error($revision_id) )
@@ -5176,8 +5215,6 @@ function wp_restore_post_revision( $revision_id, $fields = null ) {
$update['ID'] = $revision['post_parent'];
$update = add_magic_quotes( $update ); //since data is from db
$post_id = wp_update_post( $update );
if ( is_wp_error( $post_id ) )
return $post_id;
@@ -5399,7 +5436,7 @@ function set_post_thumbnail( $post, $thumbnail_id ) {
$thumbnail_id = absint( $thumbnail_id );
if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
if ( $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
return wp_update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
else
return delete_post_meta( $post->ID, '_thumbnail_id' );
}
-5
View File
@@ -1733,7 +1733,6 @@ class WP_Query {
// Category stuff
if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && $this->query_vars_changed ) {
$q['cat'] = ''.urldecode($q['cat']).'';
$q['cat'] = addslashes_gpc($q['cat']);
$cat_array = preg_split('/[,\s]+/', $q['cat']);
$q['cat'] = '';
$req_cats = array();
@@ -2180,8 +2179,6 @@ class WP_Query {
// If a search pattern is specified, load the posts that match
if ( !empty($q['s']) ) {
// added slashes screw with quote grouping when done early, so done later
$q['s'] = stripslashes($q['s']);
if ( empty( $_GET['s'] ) && $this->is_main_query() )
$q['s'] = urldecode($q['s']);
if ( !empty($q['sentence']) ) {
@@ -2290,7 +2287,6 @@ class WP_Query {
$whichauthor = '';
} else {
$q['author'] = (string)urldecode($q['author']);
$q['author'] = addslashes_gpc($q['author']);
if ( strpos($q['author'], '-') !== false ) {
$eq = '!=';
$andor = 'AND';
@@ -2352,7 +2348,6 @@ class WP_Query {
$allowed_keys[] = 'meta_value_num';
}
$q['orderby'] = urldecode($q['orderby']);
$q['orderby'] = addslashes_gpc($q['orderby']);
$orderby_array = array();
foreach ( explode( ' ', $q['orderby'] ) as $i => $orderby ) {
+1 -14
View File
@@ -953,8 +953,6 @@ function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw
if ( empty($value) )
return false;
} else if ( 'name' == $field ) {
// Assume already escaped
$value = stripslashes($value);
$field = 't.name';
} else {
$term = get_term( (int) $value, $taxonomy, $output, $filter);
@@ -1494,7 +1492,7 @@ function term_exists($term, $taxonomy = '', $parent = 0) {
return $wpdb->get_var( $wpdb->prepare( $select . $where, $term ) );
}
$term = trim( stripslashes( $term ) );
$term = trim( $term );
if ( '' === $slug = sanitize_title($term) )
return 0;
@@ -2056,10 +2054,6 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
$args = sanitize_term($args, $taxonomy, 'db');
extract($args, EXTR_SKIP);
// expected_slashed ($name)
$name = stripslashes($name);
$description = stripslashes($description);
if ( empty($slug) )
$slug = sanitize_title($name);
@@ -2439,9 +2433,6 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
if ( is_wp_error( $term ) )
return $term;
// Escape data pulled from DB.
$term = add_magic_quotes($term);
// Merge old and new args with new args overwriting old ones.
$args = array_merge($term, $args);
@@ -2450,10 +2441,6 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
$args = sanitize_term($args, $taxonomy, 'db');
extract($args, EXTR_SKIP);
// expected_slashed ($name)
$name = stripslashes($name);
$description = stripslashes($description);
if ( '' == trim($name) )
return new WP_Error('empty_term_name', __('A name is required for this term'));
+2 -6
View File
@@ -1390,7 +1390,6 @@ function wp_insert_user( $userdata ) {
}
$data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
$data = stripslashes_deep( $data );
if ( $update ) {
$wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
@@ -1462,9 +1461,6 @@ function wp_update_user($userdata) {
$user[ $key ] = get_user_meta( $ID, $key, true );
}
// Escape data pulled from DB.
$user = add_magic_quotes( $user );
// If password is changing, hash it now.
if ( ! empty($userdata['user_pass']) ) {
$plaintext_pass = $userdata['user_pass'];
@@ -1504,8 +1500,8 @@ function wp_update_user($userdata) {
* @return int The new user's ID.
*/
function wp_create_user($username, $password, $email = '') {
$user_login = esc_sql( $username );
$user_email = esc_sql( $email );
$user_login = $username;
$user_email = $email;
$user_pass = $password;
$userdata = compact('user_login', 'user_email', 'user_pass');
+1 -1
View File
@@ -224,7 +224,7 @@ class WP_Widget {
}
foreach ( $settings as $number => $new_instance ) {
$new_instance = stripslashes_deep($new_instance);
$new_instance = wp_unslash($new_instance);
$this->_set($number);
$old_instance = isset($all_instances[$number]) ? $all_instances[$number] : array();