WordPress.org

Make WordPress Core

Ticket #21767: 21767.4.diff

File 21767.4.diff, 66.6 KB (added by ryan, 5 years ago)

More stripslashes/stripslashes_deep to wp_unslash conversion

  • wp-login.php

     
    396396        }
    397397
    398398        // 10 days
    399         setcookie( 'wp-postpass_' . COOKIEHASH, $wp_hasher->HashPassword( stripslashes( $_POST['post_password'] ) ), time() + 10 * DAY_IN_SECONDS, COOKIEPATH );
     399        setcookie( 'wp-postpass_' . COOKIEHASH, $wp_hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), time() + 10 * DAY_IN_SECONDS, COOKIEPATH );
    400400
    401401        wp_safe_redirect( wp_get_referer() );
    402402        exit();
     
    431431        do_action('lost_password');
    432432        login_header(__('Lost Password'), '<p class="message">' . __('Please enter your username or email address. You will receive a link to create a new password via email.') . '</p>', $errors);
    433433
    434         $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : '';
     434        $user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : '';
    435435
    436436?>
    437437
  • wp-comments-post.php

     
    1717
    1818nocache_headers();
    1919
    20 $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
     20$post_data = wp_unslash( $_POST );
    2121
     22$comment_post_ID = isset($post_data['comment_post_ID']) ? (int) $post_data['comment_post_ID'] : 0;
     23
    2224$post = get_post($comment_post_ID);
    2325
    2426if ( empty($post->comment_status) ) {
     
    4749        do_action('pre_comment_on_post', $comment_post_ID);
    4850}
    4951
    50 $comment_author       = ( isset($_POST['author']) )  ? trim(strip_tags($_POST['author'])) : null;
    51 $comment_author_email = ( isset($_POST['email']) )   ? trim($_POST['email']) : null;
    52 $comment_author_url   = ( isset($_POST['url']) )     ? trim($_POST['url']) : null;
    53 $comment_content      = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;
     52$comment_author       = ( isset( $post_data['author'] ) )  ? trim( strip_tags( $post_data['author'] ) ) : null;
     53$comment_author_email = ( isset( $post_data['email'] ) )   ? trim( $post_data['email'] ) : null;
     54$comment_author_url   = ( isset( $post_data['url'] ) )     ? trim( $post_data['url'] ) : null;
     55$comment_content      = ( isset( $post_data['comment'] ) ) ? trim( $post_data['comment'] ) : null;
    5456
    5557// If the user is logged in
    5658$user = wp_get_current_user();
     
    6163        $comment_author_email = $wpdb->escape($user->user_email);
    6264        $comment_author_url   = $wpdb->escape($user->user_url);
    6365        if ( current_user_can('unfiltered_html') ) {
    64                 if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) {
     66                if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $post_data['_wp_unfiltered_html_comment'] ) {
    6567                        kses_remove_filters(); // start with a clean slate
    6668                        kses_init_filters(); // set up the filters
    6769                }
     
    8385if ( '' == $comment_content )
    8486        wp_die( __('<strong>ERROR</strong>: please type a comment.') );
    8587
    86 $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0;
     88$comment_parent = isset($post_data['comment_parent']) ? absint($post_data['comment_parent']) : 0;
    8789
    8890$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
    8991
     
    9294$comment = get_comment($comment_id);
    9395do_action('set_comment_cookies', $comment, $user);
    9496
    95 $location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;
     97$location = empty($post_data['redirect_to']) ? get_comment_link($comment_id) : $post_data['redirect_to'] . '#comment-' . $comment_id;
    9698$location = apply_filters('comment_post_redirect', $location, $comment);
    9799
    98100wp_safe_redirect( $location );
  • wp-includes/default-filters.php

     
    1414
    1515// Strip, trim, kses, special chars for string saves
    1616foreach ( 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 ) {
    17         add_filter( $filter, 'sanitize_text_field'  );
    18         add_filter( $filter, 'wp_filter_kses'      );
     17        add_filter( $filter, 'sanitize_text_field' );
     18        add_filter( $filter, 'wp_kses_data' );
    1919        add_filter( $filter, '_wp_specialchars', 30 );
    2020}
    2121
     
    3131
    3232// Kses only for textarea saves
    3333foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) {
    34         add_filter( $filter, 'wp_filter_kses' );
     34        add_filter( $filter, 'wp_kses_data' );
    3535}
    3636
    3737// Kses only for textarea admin displays
    3838if ( is_admin() ) {
    39         foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) {
     39        foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description', 'comment_text' ) as $filter ) {
    4040                add_filter( $filter, 'wp_kses_data' );
    4141        }
    42         add_filter( 'comment_text', 'wp_kses_post' );
    4342}
    4443
    4544// Email saves
    4645foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) {
    4746        add_filter( $filter, 'trim'           );
    4847        add_filter( $filter, 'sanitize_email' );
    49         add_filter( $filter, 'wp_filter_kses' );
     48        add_filter( $filter, 'wp_kses_data' );
    5049}
    5150
    5251// Email admin display
  • wp-includes/taxonomy.php

     
    20612061        $args = sanitize_term($args, $taxonomy, 'db');
    20622062        extract($args, EXTR_SKIP);
    20632063
    2064         // expected_slashed ($name)
    2065         $name = stripslashes($name);
    2066         $description = stripslashes($description);
    2067 
    20682064        if ( empty($slug) )
    20692065                $slug = sanitize_title($name);
    20702066
     
    23602356        if ( is_wp_error( $term ) )
    23612357                return $term;
    23622358
    2363         // Escape data pulled from DB.
    2364         $term = add_magic_quotes($term);
    2365 
    23662359        // Merge old and new args with new args overwriting old ones.
    23672360        $args = array_merge($term, $args);
    23682361
     
    23712364        $args = sanitize_term($args, $taxonomy, 'db');
    23722365        extract($args, EXTR_SKIP);
    23732366
    2374         // expected_slashed ($name)
    2375         $name = stripslashes($name);
    2376         $description = stripslashes($description);
    2377 
    23782367        if ( '' == trim($name) )
    23792368                return new WP_Error('empty_term_name', __('A name is required for this term'));
    23802369
  • wp-includes/post.php

     
    17421742 * @link http://codex.wordpress.org/Function_Reference/add_post_meta
    17431743 *
    17441744 * @param int $post_id Post ID.
    1745  * @param string $meta_key Metadata name.
    1746  * @param mixed $meta_value Metadata value.
     1745 * @param string $meta_key Metadata name (expected slashed).
     1746 * @param mixed $meta_value Metadata value (expected slashed).
    17471747 * @param bool $unique Optional, default is false. Whether the same key should not be added.
    17481748 * @return bool False for failure. True for success.
    17491749 */
    1750 function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) {
     1750function add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
     1751        _deprecated_function( __FUNCTION__, '3.5', 'wp_add_post_meta() (expects unslashed data)' );
     1752
     1753        // expected slashed
     1754        $meta_key = stripslashes( $meta_key );
     1755        $meta_value = stripslashes_deep( $meta_value );
     1756
     1757        return wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique );
     1758}
     1759
     1760/**
     1761 * Add meta data field to a post.
     1762 *
     1763 * Post meta data is called "Custom Fields" on the Administration Screen.
     1764 *
     1765 * @since 3.6.0
     1766 * @link http://codex.wordpress.org/Function_Reference/wp_add_post_meta
     1767 *
     1768 * @param int $post_id Post ID.
     1769 * @param string $meta_key Metadata name (clean, slashes already stripped).
     1770 * @param mixed $meta_value Metadata value (clean, slashes already stripped).
     1771 * @param bool $unique Optional, default is false. Whether the same key should not be added.
     1772 * @return bool False for failure. True for success.
     1773 */
     1774function wp_add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
    17511775        // make sure meta is added to the post, not a revision
    1752         if ( $the_post = wp_is_post_revision($post_id) )
     1776        if ( $the_post = wp_is_post_revision( $post_id ) )
    17531777                $post_id = $the_post;
    17541778
    1755         return add_metadata('post', $post_id, $meta_key, $meta_value, $unique);
     1779        return add_metadata( 'post', $post_id, $meta_key, $meta_value, $unique );
    17561780}
    17571781
    17581782/**
     
    18091833 * @link http://codex.wordpress.org/Function_Reference/update_post_meta
    18101834 *
    18111835 * @param int $post_id Post ID.
    1812  * @param string $meta_key Metadata key.
    1813  * @param mixed $meta_value Metadata value.
     1836 * @param string $meta_key Metadata key (expected slashed).
     1837 * @param mixed $meta_value Metadata value (expected slashed).
    18141838 * @param mixed $prev_value Optional. Previous value to check before removing.
    18151839 * @return bool False on failure, true if success.
    18161840 */
    1817 function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
     1841function update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
     1842        _deprecated_function( __FUNCTION__, '3.5', 'wp_update_post_meta() (expects unslashed data)' );
     1843
     1844        // expected slashed
     1845        $meta_key = stripslashes( $meta_key );
     1846        $meta_value = stripslashes_deep( $meta_value );
     1847
     1848        return wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value );
     1849}
     1850
     1851/**
     1852 * Update post meta field based on post ID.
     1853 *
     1854 * Use the $prev_value parameter to differentiate between meta fields with the
     1855 * same key and post ID.
     1856 *
     1857 * If the meta field for the post does not exist, it will be added.
     1858 *
     1859 * @since 3.6.0
     1860 * @uses $wpdb
     1861 * @link http://codex.wordpress.org/Function_Reference/wp_update_post_meta
     1862 *
     1863 * @param int $post_id Post ID.
     1864 * @param string $meta_key Metadata key (clean, slashes already stripped).
     1865 * @param mixed $meta_value Metadata value (clean, slashes already stripped).
     1866 * @param mixed $prev_value Optional. Previous value to check before removing.
     1867 * @return bool False on failure, true if success.
     1868 */
     1869function wp_update_post_meta( $post_id, $meta_key, $meta_value, $prev_value = '' ) {
    18181870        // make sure meta is added to the post, not a revision
    1819         if ( $the_post = wp_is_post_revision($post_id) )
     1871        if ( $the_post = wp_is_post_revision( $post_id ) )
    18201872                $post_id = $the_post;
    18211873
    1822         return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value);
     1874        return update_metadata( 'post', $post_id, $meta_key, $meta_value, $prev_value );
    18231875}
    18241876
    18251877/**
     
    24062458
    24072459        do_action('wp_trash_post', $post_id);
    24082460
    2409         add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
    2410         add_post_meta($post_id,'_wp_trash_meta_time', time());
     2461        wp_add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
     2462        wp_add_post_meta($post_id,'_wp_trash_meta_time', time());
    24112463
    24122464        $post['post_status'] = 'trash';
    24132465        wp_insert_post($post);
     
    24832535        $statuses = array();
    24842536        foreach ( $comments as $comment )
    24852537                $statuses[$comment->comment_ID] = $comment->comment_approved;
    2486         add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
     2538        wp_add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);
    24872539
    24882540        // Set status for all comments to post-trashed
    24892541        $result = $wpdb->update($wpdb->comments, array('comment_approved' => 'post-trashed'), array('comment_post_ID' => $post_id));
     
    28592911
    28602912        $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
    28612913
    2862         // expected_slashed (everything!)
    28632914        $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' ) );
    28642915        $data = apply_filters('wp_insert_post_data', $data, $postarr);
    2865         $data = stripslashes_deep( $data );
    28662916        $where = array( 'ID' => $post_ID );
    28672917
    28682918        if ( $update ) {
     
    28752925                }
    28762926        } else {
    28772927                if ( isset($post_mime_type) )
    2878                         $data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update
     2928                        $data['post_mime_type'] = $post_mime_type; // This isn't in the update
    28792929                // If there is a suggested ID, use it if not already present
    28802930                if ( !empty($import_id) ) {
    28812931                        $import_id = (int) $import_id;
     
    29362986                        else
    29372987                                return 0;
    29382988                }
    2939                 update_post_meta($post_ID, '_wp_page_template',  $page_template);
     2989                wp_update_post_meta($post_ID, '_wp_page_template',  $page_template);
    29402990        }
    29412991
    29422992        wp_transition_post_status($data['post_status'], $previous_status, $post);
     
    29693019        if ( is_object($postarr) ) {
    29703020                // non-escaped post was passed
    29713021                $postarr = get_object_vars($postarr);
    2972                 $postarr = add_magic_quotes($postarr);
    29733022        }
    29743023
    29753024        // First, get all of the original fields
    29763025        $post = get_post($postarr['ID'], ARRAY_A);
    29773026
    2978         // Escape data pulled from DB.
    2979         $post = add_magic_quotes($post);
    2980 
    29813027        // Passed post category list overwrites existing category list if not empty.
    29823028        if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
    29833029                         && 0 != count($postarr['post_category']) )
     
    39624008        else
    39634009                $post_name = sanitize_title($post_name);
    39644010
    3965         // expected_slashed ($post_name)
    39664011        $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
    39674012
    39684013        if ( empty($post_date) )
     
    40054050        if ( ! isset($pinged) )
    40064051                $pinged = '';
    40074052
    4008         // expected_slashed (everything!)
    40094053        $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' ) );
    4010         $data = stripslashes_deep( $data );
    40114054
    40124055        if ( $update ) {
    40134056                $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) );
     
    40524095        clean_post_cache( $post_ID );
    40534096
    40544097        if ( ! empty( $context ) )
    4055                 add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
     4098                wp_add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
    40564099
    40574100        if ( $update) {
    40584101                do_action('edit_attachment', $post_ID);
     
    44394482
    44404483        // if we haven't added this old slug before, add it now
    44414484        if ( !empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) )
    4442                 add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
     4485                wp_add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);
    44434486
    44444487        // if the new slug was used previously, delete it from the list
    44454488        if ( in_array($post->post_name, $old_slugs) )
     
    48614904                return;
    48624905
    48634906        if ( get_option('default_pingback_flag') )
    4864                 add_post_meta( $post_id, '_pingme', '1' );
    4865         add_post_meta( $post_id, '_encloseme', '1' );
     4907                wp_add_post_meta( $post_id, '_pingme', '1' );
     4908        wp_add_post_meta( $post_id, '_encloseme', '1' );
    48664909
    48674910        wp_schedule_single_event(time(), 'do_pings');
    48684911}
     
    50885131                return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) );
    50895132
    50905133        $post = _wp_post_revision_fields( $post, $autosave );
    5091         $post = add_magic_quotes($post); //since data is from db
    50925134
    50935135        $revision_id = wp_insert_post( $post );
    50945136        if ( is_wp_error($revision_id) )
     
    51675209
    51685210        $update['ID'] = $revision['post_parent'];
    51695211
    5170         $update = add_magic_quotes( $update ); //since data is from db
    5171 
    51725212        $post_id = wp_update_post( $update );
    51735213        if ( is_wp_error( $post_id ) )
    51745214                return $post_id;
     
    53905430        $thumbnail_id = absint( $thumbnail_id );
    53915431        if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) {
    53925432                if ( $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
    5393                         return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
     5433                        return wp_update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );
    53945434                else
    53955435                        return delete_post_meta( $post->ID, '_thumbnail_id' );
    53965436        }
  • wp-includes/comment.php

     
    633633 */
    634634function sanitize_comment_cookies() {
    635635        if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) {
    636                 $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]);
    637                 $comment_author = stripslashes($comment_author);
     636                $comment_author = stripslashes($_COOKIE['comment_author_'.COOKIEHASH]);
     637                $comment_author = apply_filters('pre_comment_author_name', $comment_author);
    638638                $comment_author = esc_attr($comment_author);
    639639                $_COOKIE['comment_author_'.COOKIEHASH] = $comment_author;
    640640        }
    641641
    642642        if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
    643                 $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
    644                 $comment_author_email = stripslashes($comment_author_email);
     643                $comment_author_email = stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH]);
     644                $comment_author_email = apply_filters('pre_comment_author_email', $comment_author_email);
    645645                $comment_author_email = esc_attr($comment_author_email);
    646646                $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
    647647        }
    648648
    649649        if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) {
    650                 $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]);
    651                 $comment_author_url = stripslashes($comment_author_url);
     650                $comment_author_url = stripslashes($_COOKIE['comment_author_url_'.COOKIEHASH]);
     651                $comment_author_url = apply_filters('pre_comment_author_url', $comment_author_url);
    652652                $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url;
    653653        }
    654654}
     
    670670        extract($commentdata, EXTR_SKIP);
    671671
    672672        // Simple duplicate check
    673         // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)
    674         $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' ";
     673        $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 );
    675674        if ( $comment_author_email )
    676                 $dupe .= "OR comment_author_email = '$comment_author_email' ";
    677         $dupe .= ") AND comment_content = '$comment_content' LIMIT 1";
     675                $dupe .= $wpdb->prepare( "OR comment_author_email = %s ", $comment_author_email );
     676        $dupe .= $wpdb->prepare( ") AND comment_content = %s LIMIT 1", $comment_content );
    678677        if ( $wpdb->get_var($dupe) ) {
    679678                do_action( 'comment_duplicate_trigger', $commentdata );
    680679                if ( defined('DOING_AJAX') )
     
    12621261 */
    12631262function wp_insert_comment($commentdata) {
    12641263        global $wpdb;
    1265         extract(stripslashes_deep($commentdata), EXTR_SKIP);
     1264        extract($commentdata, EXTR_SKIP);
    12661265
    12671266        if ( ! isset($comment_author_IP) )
    12681267                $comment_author_IP = '';
     
    15071506        $commentarr = wp_filter_comment( $commentarr );
    15081507
    15091508        // Now extract the merged array.
    1510         extract(stripslashes_deep($commentarr), EXTR_SKIP);
     1509        extract($commentarr, EXTR_SKIP);
    15111510
    15121511        $comment_content = apply_filters('comment_save_pre', $comment_content);
    15131512
  • wp-includes/functions.php

     
    468468                                }
    469469
    470470                                if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
    471                                         add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
     471                                        wp_add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
    472472                                }
    473473                        }
    474474                }
  • wp-includes/user.php

     
    13901390        }
    13911391
    13921392        $data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' );
    1393         $data = stripslashes_deep( $data );
    13941393
    13951394        if ( $update ) {
    13961395                $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
     
    14621461                $user[ $key ] = get_user_meta( $ID, $key, true );
    14631462        }
    14641463
    1465         // Escape data pulled from DB.
    1466         $user = add_magic_quotes( $user );
    1467 
    14681464        // If password is changing, hash it now.
    14691465        if ( ! empty($userdata['user_pass']) ) {
    14701466                $plaintext_pass = $userdata['user_pass'];
  • wp-includes/class-wp-xmlrpc-server.php

     
    276276                $post_id = (int) $post_id;
    277277
    278278                foreach ( (array) $fields as $meta ) {
     279                        $meta['key'] = stripslashes( $meta['key'] );
     280                        $meta['value'] = stripslashes_deep( $meta['value'] );
    279281                        if ( isset($meta['id']) ) {
    280282                                $meta['id'] = (int) $meta['id'];
    281283                                $pmeta = get_metadata_by_mid( 'post', $meta['id'] );
    282284                                if ( isset($meta['key']) ) {
    283                                         $meta['key'] = stripslashes( $meta['key'] );
    284285                                        if ( $meta['key'] != $pmeta->meta_key )
    285286                                                continue;
    286                                         $meta['value'] = stripslashes_deep( $meta['value'] );
    287287                                        if ( current_user_can( 'edit_post_meta', $post_id, $meta['key'] ) )
    288288                                                update_metadata_by_mid( 'post', $meta['id'], $meta['value'] );
    289289                                } elseif ( current_user_can( 'delete_post_meta', $post_id, $pmeta->meta_key ) ) {
    290290                                        delete_metadata_by_mid( 'post', $meta['id'] );
    291291                                }
    292292                        } elseif ( current_user_can( 'add_post_meta', $post_id, stripslashes( $meta['key'] ) ) ) {
    293                                 add_post_meta( $post_id, $meta['key'], $meta['value'] );
     293                                wp_add_post_meta( $post_id, $meta['key'], $meta['value'] );
    294294                        }
    295295                }
    296296        }
     
    43164316                                }
    43174317                        }
    43184318                        if (!$found)
    4319                                 add_post_meta( $post_ID, 'enclosure', $encstring );
     4319                                wp_add_post_meta( $post_ID, 'enclosure', $encstring );
    43204320                }
    43214321        }
    43224322
     
    52745274                // retain old cats
    52755275                $cats = wp_get_post_categories($post_ID);
    52765276                $postdata['post_category'] = $cats;
    5277                 $this->escape($postdata);
    52785277
    52795278                $result = wp_update_post($postdata);
    52805279
  • wp-includes/formatting.php

     
    17161716 * @return string Converted content.
    17171717 */
    17181718function wp_rel_nofollow( $text ) {
    1719         // This is a pre save filter, so text is already escaped.
    1720         $text = stripslashes($text);
    17211719        $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text);
    1722         $text = esc_sql($text);
    17231720        return $text;
    17241721}
    17251722
     
    33423339        $urls_to_ping = implode( "\n", $urls_to_ping );
    33433340        return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping );
    33443341}
     3342
     3343/**
     3344 * Slash a string or array of strings.
     3345 *
     3346 * This should be used only for GPC data.
     3347 *
     3348 * @since 3.6.0
     3349 *
     3350 * @param string|array $value String or array of strings to slash.
     3351 * @return string|array Slashed $value
     3352 */
     3353function wp_slash( $value ) {
     3354        if ( is_array( $value ) ) {
     3355                array_map( 'wp_slash', $value);
     3356        } else {
     3357                $value = addslashes( $value );
     3358        }
     3359
     3360        return $value;
     3361}
     3362
     3363/**
     3364 * Remove slashes a string or array of strings.
     3365 *
     3366 * This should be used for GPC data before passing it along to core API.
     3367 *
     3368 * @since 3.6.0
     3369 *
     3370 * @param string|array $value String or array of strings to unslash.
     3371 * @return string|array Unslashed $value
     3372 */
     3373function wp_unslash( $value ) {
     3374        return stripslashes_deep( $value );
     3375}
  • wp-includes/kses.php

     
    13261326 */
    13271327function kses_init_filters() {
    13281328        // Normal filtering
    1329         add_filter('title_save_pre', 'wp_filter_kses');
     1329        add_filter('title_save_pre', 'wp_kses_data');
    13301330
    13311331        // Comment filtering
    13321332        if ( current_user_can( 'unfiltered_html' ) )
    1333                 add_filter( 'pre_comment_content', 'wp_filter_post_kses' );
     1333                add_filter( 'pre_comment_content', 'wp_kses_post' );
    13341334        else
    1335                 add_filter( 'pre_comment_content', 'wp_filter_kses' );
     1335                add_filter( 'pre_comment_content', 'wp_kses_data' );
    13361336
    13371337        // Post filtering
    1338         add_filter('content_save_pre', 'wp_filter_post_kses');
    1339         add_filter('excerpt_save_pre', 'wp_filter_post_kses');
    1340         add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
     1338        add_filter('content_save_pre', 'wp_kses_post');
     1339        add_filter('excerpt_save_pre', 'wp_kses_post');
     1340        add_filter('content_filtered_save_pre', 'wp_kses_post');
    13411341}
    13421342
    13431343/**
     
    13541354 */
    13551355function kses_remove_filters() {
    13561356        // Normal filtering
    1357         remove_filter('title_save_pre', 'wp_filter_kses');
     1357        remove_filter('title_save_pre', 'wp_kses_data');
    13581358
    13591359        // Comment filtering
    1360         remove_filter( 'pre_comment_content', 'wp_filter_post_kses' );
    1361         remove_filter( 'pre_comment_content', 'wp_filter_kses' );
     1360        remove_filter( 'pre_comment_content', 'wp_kses_post' );
     1361        remove_filter( 'pre_comment_content', 'wp_kses_data' );
    13621362
    13631363        // Post filtering
    1364         remove_filter('content_save_pre', 'wp_filter_post_kses');
    1365         remove_filter('excerpt_save_pre', 'wp_filter_post_kses');
    1366         remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
     1364        remove_filter('content_save_pre', 'wp_kses_post');
     1365        remove_filter('excerpt_save_pre', 'wp_kses_post');
     1366        remove_filter('content_filtered_save_pre', 'wp_kses_post');
    13671367}
    13681368
    13691369/**
  • wp-includes/meta.php

     
    4242
    4343        $column = esc_sql($meta_type . '_id');
    4444
    45         // expected_slashed ($meta_key)
    46         $meta_key = stripslashes($meta_key);
    47         $meta_value = stripslashes_deep($meta_value);
    4845        $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type );
    4946
    5047        $check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique );
     
    113110        $column = esc_sql($meta_type . '_id');
    114111        $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id';
    115112
    116         // expected_slashed ($meta_key)
    117         $meta_key = stripslashes($meta_key);
    118113        $passed_value = $meta_value;
    119         $meta_value = stripslashes_deep($meta_value);
    120114        $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type );
    121115
    122116        $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value );
  • wp-includes/nav-menu.php

     
    369369
    370370        $menu_item_db_id = (int) $menu_item_db_id;
    371371
    372         update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($args['menu-item-type']) );
    373         update_post_meta( $menu_item_db_id, '_menu_item_menu_item_parent', strval( (int) $args['menu-item-parent-id'] ) );
    374         update_post_meta( $menu_item_db_id, '_menu_item_object_id', strval( (int) $args['menu-item-object-id'] ) );
    375         update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($args['menu-item-object']) );
    376         update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($args['menu-item-target']) );
     372        wp_update_post_meta( $menu_item_db_id, '_menu_item_type', sanitize_key($args['menu-item-type']) );
     373        wp_update_post_meta( $menu_item_db_id, '_menu_item_menu_item_parent', strval( (int) $args['menu-item-parent-id'] ) );
     374        wp_update_post_meta( $menu_item_db_id, '_menu_item_object_id', strval( (int) $args['menu-item-object-id'] ) );
     375        wp_update_post_meta( $menu_item_db_id, '_menu_item_object', sanitize_key($args['menu-item-object']) );
     376        wp_update_post_meta( $menu_item_db_id, '_menu_item_target', sanitize_key($args['menu-item-target']) );
    377377
    378378        $args['menu-item-classes'] = array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-classes'] ) );
    379379        $args['menu-item-xfn'] = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-xfn'] ) ) );
    380         update_post_meta( $menu_item_db_id, '_menu_item_classes', $args['menu-item-classes'] );
    381         update_post_meta( $menu_item_db_id, '_menu_item_xfn', $args['menu-item-xfn'] );
    382         update_post_meta( $menu_item_db_id, '_menu_item_url', esc_url_raw($args['menu-item-url']) );
     380        wp_update_post_meta( $menu_item_db_id, '_menu_item_classes', $args['menu-item-classes'] );
     381        wp_update_post_meta( $menu_item_db_id, '_menu_item_xfn', $args['menu-item-xfn'] );
     382        wp_update_post_meta( $menu_item_db_id, '_menu_item_url', esc_url_raw($args['menu-item-url']) );
    383383
    384384        if ( 0 == $menu_id )
    385                 update_post_meta( $menu_item_db_id, '_menu_item_orphaned', (string) time() );
     385                wp_update_post_meta( $menu_item_db_id, '_menu_item_orphaned', (string) time() );
    386386        elseif ( get_post_meta( $menu_item_db_id, '_menu_item_orphaned' ) )
    387387                delete_post_meta( $menu_item_db_id, '_menu_item_orphaned' );
    388388
  • wp-mail.php

     
    202202        $post_category = array(get_option('default_email_category'));
    203203
    204204        $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
    205         $post_data = add_magic_quotes($post_data);
    206205
    207206        $post_ID = wp_insert_post($post_data);
    208207        if ( is_wp_error( $post_ID ) )
  • wp-trackback.php

     
    4545$charset = isset($_POST['charset']) ? $_POST['charset'] : '';
    4646
    4747// These three are stripslashed here so that they can be properly escaped after mb_convert_encoding()
    48 $title     = isset($_POST['title'])     ? stripslashes($_POST['title'])      : '';
    49 $excerpt   = isset($_POST['excerpt'])   ? stripslashes($_POST['excerpt'])    : '';
    50 $blog_name = isset($_POST['blog_name']) ? stripslashes($_POST['blog_name'])  : '';
     48$title     = isset($_POST['title'])     ? wp_unslash( $_POST['title'] )      : '';
     49$excerpt   = isset($_POST['excerpt'])   ? wp_unslash( $_POST['excerpt'] )    : '';
     50$blog_name = isset($_POST['blog_name']) ? wp_unslash( $_POST['blog_name'] )  : '';
    5151
    5252if ($charset)
    5353        $charset = str_replace( array(',', ' '), '', strtoupper( trim($charset) ) );
     
    6464        $blog_name = mb_convert_encoding($blog_name, get_option('blog_charset'), $charset);
    6565}
    6666
    67 // Now that mb_convert_encoding() has been given a swing, we need to escape these three
    68 $title     = $wpdb->escape($title);
    69 $excerpt   = $wpdb->escape($excerpt);
    70 $blog_name = $wpdb->escape($blog_name);
    71 
    7267if ( is_single() || is_page() )
    7368        $tb_id = $posts[0]->ID;
    7469
  • wp-admin/edit-comments.php

     
    9595        wp_safe_redirect( $redirect_to );
    9696        exit;
    9797} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
    98          wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
     98         wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
    9999         exit;
    100100}
    101101
     
    153153        echo __('Comments');
    154154
    155155if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
    156         printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ) . '</span>' ); ?>
     156        printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50 ) ) . '</span>' ); ?>
    157157</h2>
    158158
    159159<?php
  • wp-admin/includes/bookmark.php

     
    3939
    4040        if ( !empty( $link_id ) ) {
    4141                $_POST['link_id'] = $link_id;
    42                 return wp_update_link( $_POST );
     42                return wp_update_link( stripslashes_deep( $_POST ) );
    4343        } else {
    44                 return wp_insert_link( $_POST );
     44                return wp_insert_link( stripslashes_deep( $_POST ) );
    4545        }
    4646}
    4747
     
    137137        $linkdata = wp_parse_args( $linkdata, $defaults );
    138138        $linkdata = sanitize_bookmark( $linkdata, 'db' );
    139139
    140         extract( stripslashes_deep( $linkdata ), EXTR_SKIP );
     140        extract( $linkdata, EXTR_SKIP );
    141141
    142142        $update = false;
    143143
     
    250250
    251251        $link = get_bookmark( $link_id, ARRAY_A );
    252252
    253         // Escape data pulled from DB.
    254         $link = add_magic_quotes( $link );
    255 
    256253        // Passed link category list overwrites existing category list if not empty.
    257254        if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
    258255                         && 0 != count( $linkdata['link_category'] ) )
  • wp-admin/includes/taxonomy.php

     
    157157        // First, get all of the original fields
    158158        $category = get_category($cat_ID, ARRAY_A);
    159159
    160         // Escape data pulled from DB.
    161         $category = add_magic_quotes($category);
    162 
    163160        // Merge old and new fields with new fields overwriting old ones.
    164161        $catarr = array_merge($category, $catarr);
    165162
  • wp-admin/includes/ajax-actions.php

     
    5959                wp_die( 0 );
    6060        }
    6161
    62         $s = stripslashes( $_GET['q'] );
     62        $s = wp_unslash( $_GET['q'] );
    6363
    6464        $comma = _x( ',', 'tag delimiter' );
    6565        if ( ',' !== $comma )
     
    279279 */
    280280
    281281function _wp_ajax_add_hierarchical_term() {
    282         $action = $_POST['action'];
     282        $post_data = wp_unslash( $_POST );
     283
     284        $action = $post_data['action'];
    283285        $taxonomy = get_taxonomy(substr($action, 4));
    284286        check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
    285287        if ( !current_user_can( $taxonomy->cap->edit_terms ) )
    286288                wp_die( -1 );
    287         $names = explode(',', $_POST['new'.$taxonomy->name]);
    288         $parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
     289        $names = explode(',', $post_data['new'.$taxonomy->name]);
     290        $parent = isset($post_data['new'.$taxonomy->name.'_parent']) ? (int) $post_data['new'.$taxonomy->name.'_parent'] : 0;
    289291        if ( 0 > $parent )
    290292                $parent = 0;
    291293        if ( $taxonomy->name == 'category' )
    292                 $post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
     294                $post_category = isset( $post_data['post_category'] ) ? (array) $post_data['post_category'] : array();
    293295        else
    294                 $post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
     296                $post_category = ( isset( $post_data['tax_input'] ) && isset( $post_data['tax_input'][$taxonomy->name] ) ) ? (array) $post_data['tax_input'][$taxonomy->name] : array();
    295297        $checked_categories = array_map( 'absint', (array) $post_category );
    296298        $popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false);
    297299
     
    559561        check_ajax_referer( $action );
    560562        if ( !current_user_can( 'manage_categories' ) )
    561563                wp_die( -1 );
    562         $names = explode(',', $_POST['newcat']);
     564        $names = explode( ',', wp_unslash( $_POST['newcat'] ) );
    563565        $x = new WP_Ajax_Response();
    564566        foreach ( $names as $cat_name ) {
    565567                $cat_name = trim($cat_name);
     
    572574                        continue;
    573575                else if ( is_array( $cat_id ) )
    574576                        $cat_id = $cat_id['term_id'];
    575                 $cat_name = esc_html(stripslashes($cat_name));
     577                $cat_name = esc_html( wp_unslash( $cat_name ) );
    576578                $x->add( array(
    577579                        'what' => 'link-category',
    578580                        'id' => $cat_id,
     
    586588function wp_ajax_add_tag() {
    587589        global $wp_list_table;
    588590
     591        $post_data = wp_unslash( $_POST );
     592
    589593        check_ajax_referer( 'add-tag', '_wpnonce_add-tag' );
    590         $post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
    591         $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
     594        $post_type = !empty($post_data['post_type']) ? $post_data['post_type'] : 'post';
     595        $taxonomy = !empty($post_data['taxonomy']) ? $post_data['taxonomy'] : 'post_tag';
    592596        $tax = get_taxonomy($taxonomy);
    593597
    594598        if ( !current_user_can( $tax->cap->edit_terms ) )
     
    596600
    597601        $x = new WP_Ajax_Response();
    598602
    599         $tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
     603        $tag = wp_insert_term( $post_data['tag-name'], $taxonomy, $post_data );
    600604
    601605        if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
    602606                $message = __('An error has occurred. Please reload the page and try again.');
     
    610614                $x->send();
    611615        }
    612616
    613         $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen'] ) );
     617        $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $post_data['screen'] ) );
    614618
    615619        $level = 0;
    616620        if ( is_taxonomy_hierarchical($taxonomy) ) {
     
    728732        $user = wp_get_current_user();
    729733        if ( $user->exists() ) {
    730734                $user_ID = $user->ID;
    731                 $comment_author       = $wpdb->escape($user->display_name);
    732                 $comment_author_email = $wpdb->escape($user->user_email);
    733                 $comment_author_url   = $wpdb->escape($user->user_url);
    734                 $comment_content      = trim($_POST['content']);
     735                $comment_author       = $user->display_name;
     736                $comment_author_email = $user->user_email;
     737                $comment_author_url   = $user->user_url;
     738                $comment_content      = trim( wp_unslash( $_POST['content'] ) );
    735739                if ( current_user_can( 'unfiltered_html' ) ) {
    736740                        if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
    737741                                kses_remove_filters(); // start with a clean slate
     
    957961                ) );
    958962        } else { // Update?
    959963                $mid = (int) key( $_POST['meta'] );
    960                 $key = stripslashes( $_POST['meta'][$mid]['key'] );
    961                 $value = stripslashes( $_POST['meta'][$mid]['value'] );
     964                $key = wp_unslash( $_POST['meta'][$mid]['key'] );
     965                $value = wp_unslash( $_POST['meta'][$mid]['value'] );
    962966                if ( '' == trim($key) )
    963967                        wp_die( __( 'Please provide a custom field name.' ) );
    964968                if ( '' == trim($value) )
     
    12271231        $args = array();
    12281232
    12291233        if ( isset( $_POST['search'] ) )
    1230                 $args['s'] = stripslashes( $_POST['search'] );
     1234                $args['s'] = wp_unslash( $_POST['search'] );
    12311235        $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
    12321236
    12331237        require(ABSPATH . WPINC . '/class-wp-editor.php');
     
    13281332        $data = &$_POST;
    13291333
    13301334        $post = get_post( $post_ID, ARRAY_A );
    1331         $post = add_magic_quotes($post); //since it is from db
    13321335
    13331336        $data['content'] = $post['post_content'];
    13341337        $data['excerpt'] = $post['post_excerpt'];
     
    13761379        global $wp_list_table;
    13771380
    13781381        check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
     1382       
     1383        $post_data = wp_unslash( $_POST );
    13791384
    1380         $taxonomy = sanitize_key( $_POST['taxonomy'] );
     1385        $taxonomy = sanitize_key( $post_data['taxonomy'] );
    13811386        $tax = get_taxonomy( $taxonomy );
    13821387        if ( ! $tax )
    13831388                wp_die( 0 );
     
    13871392
    13881393        $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) );
    13891394
    1390         if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
     1395        if ( ! isset($post_data['tax_ID']) || ! ( $id = (int) $post_data['tax_ID'] ) )
    13911396                wp_die( -1 );
    13921397
    13931398        $tag = get_term( $id, $taxonomy );
    1394         $_POST['description'] = $tag->description;
     1399        $post_data['description'] = $tag->description;
    13951400
    1396         $updated = wp_update_term($id, $taxonomy, $_POST);
     1401        $updated = wp_update_term($id, $taxonomy, $post_data );
    13971402        if ( $updated && !is_wp_error($updated) ) {
    13981403                $tag = get_term( $updated['term_id'], $taxonomy );
    13991404                if ( !$tag || is_wp_error( $tag ) ) {
     
    14251430        $post_types = get_post_types( array( 'public' => true ), 'objects' );
    14261431        unset( $post_types['attachment'] );
    14271432
    1428         $s = stripslashes( $_POST['ps'] );
     1433        $s = wp_unslash( $_POST['ps'] );
    14291434        $searchand = $search = '';
    14301435        $args = array(
    14311436                'post_type' => array_keys( $post_types ),
     
    15961601                $post_id = null;
    15971602        }
    15981603
    1599         $post_data = isset( $_REQUEST['post_data'] ) ? $_REQUEST['post_data'] : array();
     1604        $post_data = isset( $_REQUEST['post_data'] ) ? wp_unslash( $_REQUEST['post_data'] ) : array();
    16001605
    16011606        // If the context is custom header or background, make sure the uploaded file is an image.
    16021607        if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) {
     
    16301635
    16311636        if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) {
    16321637                if ( 'custom-background' === $post_data['context'] )
    1633                         update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
     1638                        wp_update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
    16341639
    16351640                if ( 'custom-header' === $post_data['context'] )
    1636                         update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
     1641                        wp_update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
    16371642        }
    16381643
    16391644        if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) )
     
    17781783                wp_die( 0 );
    17791784
    17801785        $new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ) + 5 ) . ':' . $active_lock[1];
    1781         update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
     1786        wp_update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
    17821787        wp_die( 1 );
    17831788}
    17841789
     
    18731878        if ( ! current_user_can( 'edit_post', $id ) )
    18741879                wp_send_json_error();
    18751880
    1876         $changes = $_REQUEST['changes'];
     1881        $changes = wp_unslash( $_REQUEST['changes'] );
    18771882        $post    = get_post( $id, ARRAY_A );
    18781883
    18791884        if ( 'attachment' != $post['post_type'] )
     
    18901895
    18911896        if ( isset( $changes['alt'] ) ) {
    18921897                $alt = get_post_meta( $id, '_wp_attachment_image_alt', true );
    1893                 $new_alt = stripslashes( $changes['alt'] );
     1898                $new_alt = $changes['alt'];
    18941899                if ( $alt != $new_alt ) {
    18951900                        $new_alt = wp_strip_all_tags( $new_alt, true );
    1896                         update_post_meta( $id, '_wp_attachment_image_alt', addslashes( $new_alt ) );
     1901                        wp_update_post_meta( $id, '_wp_attachment_image_alt', $new_alt );
    18971902                }
    18981903        }
    18991904
     
    19151920
    19161921        if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) )
    19171922                wp_send_json_error();
    1918         $attachment_data = $_REQUEST['attachments'][ $id ];
     1923        $attachment_data = wp_unslash( $_REQUEST['attachments'][ $id ] );
    19191924
    19201925        check_ajax_referer( 'update-post_' . $id, 'nonce' );
    19211926
     
    19591964
    19601965        check_ajax_referer( 'update-post_' . $post_id, 'nonce' );
    19611966
    1962         $attachments = $_REQUEST['attachments'];
     1967        $attachments = wp_unslash( $_REQUEST['attachments'] );
    19631968
    19641969        if ( ! current_user_can( 'edit_post', $post_id ) )
    19651970                wp_send_json_error();
     
    19901995function wp_ajax_send_attachment_to_editor() {
    19911996        check_ajax_referer( 'media-send-to-editor', 'nonce' );
    19921997
    1993         $attachment = stripslashes_deep( $_POST['attachment'] );
     1998        $attachment = wp_unslash( $_POST['attachment'] );
    19941999
    19952000        $id = intval( $attachment['id'] );
    19962001
     
    20452050function wp_ajax_send_link_to_editor() {
    20462051        check_ajax_referer( 'media-send-to-editor', 'nonce' );
    20472052
    2048         if ( ! $src = stripslashes( $_POST['src'] ) )
     2053        if ( ! $src = wp_unslash( $_POST['src'] ) )
    20492054                wp_send_json_error();
    20502055
    20512056        if ( ! strpos( $src, '://' ) )
     
    20542059        if ( ! $src = esc_url_raw( $src ) )
    20552060                wp_send_json_error();
    20562061
    2057         if ( ! $title = trim( stripslashes( $_POST['title'] ) ) )
     2062        if ( ! $title = trim( wp_unslash( $_POST['title'] ) ) )
    20582063                $title = wp_basename( $src );
    20592064
    20602065        $html = '';
     
    20832088                $screen_id = 'site';
    20842089       
    20852090        if ( ! empty($_POST['data']) ) {
    2086                 $data = (array) $_POST['data'];
     2091                $data = wp_unslash( (array) $_POST['data'] );
    20872092                // todo: how much to sanitize and preset and what to leave to be accessed from $data or $_POST..?
    20882093                $user = wp_get_current_user();
    20892094                $data['user_id'] = $user->exists() ? $user->ID : 0;
  • wp-admin/includes/post.php

     
    149149 */
    150150function edit_post( $post_data = null ) {
    151151
    152         if ( empty($post_data) )
    153                 $post_data = &$_POST;
     152        if ( empty($post_data) ) {
     153                $post_data = stripslashes_deep( $_POST );
     154        }
    154155
    155156        // Clear out any data in internal vars.
    156157        unset( $post_data['filter'] );
     
    241242
    242243        add_meta( $post_ID );
    243244
    244         update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
     245        wp_update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
    245246
    246247        wp_update_post( $post_data );
    247248
     
    559560        }
    560561
    561562        // Create the post.
    562         $post_ID = wp_insert_post( $_POST );
     563        $post_ID = wp_insert_post( stripslashes_deep( $_POST ) );
    563564        if ( is_wp_error( $post_ID ) )
    564565                return $post_ID;
    565566
     
    568569
    569570        add_meta( $post_ID );
    570571
    571         add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
     572        wp_add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
    572573
    573574        // Now that we have an ID we can fix any attachment anchor hrefs
    574575        _fix_attachment_links( $post_ID );
     
    612613        global $wpdb;
    613614        $post_ID = (int) $post_ID;
    614615
    615         $metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : '';
    616         $metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : '';
    617         $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : '';
     616        $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';
     617        $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : '';
     618        $metavalue = isset($_POST['metavalue']) ? wp_unslash( trim( $_POST['metavalue'] ) ) : '';
    618619        if ( is_string( $metavalue ) )
    619620                $metavalue = trim( $metavalue );
    620621
     
    633634
    634635                $metakey = esc_sql( $metakey );
    635636
    636                 return add_post_meta( $post_ID, $metakey, $metavalue );
     637                return wp_add_post_meta( $post_ID, $metakey, $metavalue );
    637638        }
    638639
    639640        return false;
     
    706707 * @since 1.2.0
    707708 *
    708709 * @param unknown_type $meta_id
    709  * @param unknown_type $meta_key Expect Slashed
    710  * @param unknown_type $meta_value Expect Slashed
     710 * @param unknown_type $meta_key
     711 * @param unknown_type $meta_value
    711712 * @return unknown
    712713 */
    713714function update_meta( $meta_id, $meta_key, $meta_value ) {
    714         $meta_key = stripslashes( $meta_key );
    715         $meta_value = stripslashes_deep( $meta_value );
    716 
    717715        return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key );
    718716}
    719717
     
    767765
    768766        if ( $replace ) {
    769767                $post['post_content'] = $content;
    770                 // Escape data pulled from DB.
    771                 $post = add_magic_quotes($post);
    772768
    773769                return wp_update_post($post);
    774770        }
     
    11791175        $now = time();
    11801176        $lock = "$now:$user_id";
    11811177
    1182         update_post_meta( $post->ID, '_edit_lock', $lock );
     1178        wp_update_post_meta( $post->ID, '_edit_lock', $lock );
    11831179        return array( $now, $user_id );
    11841180}
    11851181
  • wp-admin/includes/misc.php

     
    323323
    324324                if ( !$user = wp_get_current_user() )
    325325                        return;
    326                 $option = $_POST['wp_screen_options']['option'];
    327                 $value = $_POST['wp_screen_options']['value'];
     326                $option = stripslashes( $_POST['wp_screen_options']['option'] );
     327                $value = stripslashes_deep( $_POST['wp_screen_options']['value'] );
    328328
    329329                if ( $option != sanitize_key( $option ) )
    330330                        return;
  • wp-admin/includes/comment.php

     
    1919function comment_exists($comment_author, $comment_date) {
    2020        global $wpdb;
    2121
    22         $comment_author = stripslashes($comment_author);
    23         $comment_date = stripslashes($comment_date);
    24 
    2522        return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments
    2623                        WHERE comment_author = %s AND comment_date = %s", $comment_author, $comment_date) );
    2724}
     
    3330 */
    3431function edit_comment() {
    3532
    36         if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) )
     33        $post_data = stripslashes_deep( $_POST );
     34
     35        if ( ! current_user_can( 'edit_comment', (int) $post_data['comment_ID'] ) )
    3736                wp_die ( __( 'You are not allowed to edit comments on this post.' ) );
    3837
    39         $_POST['comment_author'] = $_POST['newcomment_author'];
    40         $_POST['comment_author_email'] = $_POST['newcomment_author_email'];
    41         $_POST['comment_author_url'] = $_POST['newcomment_author_url'];
    42         $_POST['comment_approved'] = $_POST['comment_status'];
    43         $_POST['comment_content'] = $_POST['content'];
    44         $_POST['comment_ID'] = (int) $_POST['comment_ID'];
     38        $post_data['comment_author'] = $post_data['newcomment_author'];
     39        $post_data['comment_author_email'] = $post_data['newcomment_author_email'];
     40        $post_data['comment_author_url'] = $post_data['newcomment_author_url'];
     41        $post_data['comment_approved'] = $post_data['comment_status'];
     42        $post_data['comment_content'] = $post_data['content'];
     43        $post_data['comment_ID'] = (int) $post_data['comment_ID'];
    4544
    4645        foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
    47                 if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
     46                if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) {
    4847                        $_POST['edit_date'] = '1';
    4948                        break;
    5049                }
    5150        }
    5251
    53         if ( !empty ( $_POST['edit_date'] ) ) {
    54                 $aa = $_POST['aa'];
    55                 $mm = $_POST['mm'];
    56                 $jj = $_POST['jj'];
    57                 $hh = $_POST['hh'];
    58                 $mn = $_POST['mn'];
    59                 $ss = $_POST['ss'];
     52        if ( !empty ( $post_data['edit_date'] ) ) {
     53                $aa = $post_data['aa'];
     54                $mm = $post_data['mm'];
     55                $jj = $post_data['jj'];
     56                $hh = $post_data['hh'];
     57                $mn = $post_data['mn'];
     58                $ss = $post_data['ss'];
    6059                $jj = ($jj > 31 ) ? 31 : $jj;
    6160                $hh = ($hh > 23 ) ? $hh -24 : $hh;
    6261                $mn = ($mn > 59 ) ? $mn -60 : $mn;
    6362                $ss = ($ss > 59 ) ? $ss -60 : $ss;
    64                 $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
     63                $post_data['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
    6564        }
    6665
    67         wp_update_comment( $_POST );
     66        wp_update_comment( $post_data );
    6867}
    6968
    7069/**
  • wp-admin/includes/image-edit.php

     
    533533                }
    534534        }
    535535
    536         if ( !wp_update_attachment_metadata($post_id, $meta) || !update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes) ) {
     536        if ( !wp_update_attachment_metadata($post_id, $meta) || !wp_update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes) ) {
    537537                $msg->error = __('Cannot save image metadata.');
    538538                return $msg;
    539539        }
     
    699699
    700700        if ( $success ) {
    701701                wp_update_attachment_metadata( $post_id, $meta );
    702                 update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
     702                wp_update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
    703703
    704704                if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
    705705                        // Check if it's an image edit from attachment edit screen
  • wp-admin/includes/user.php

     
    3838        } else {
    3939                $update = false;
    4040        }
     41       
     42        // get clean data before we get started.
     43        $post_data = stripslashes_deep( $_POST );
    4144
    42         if ( !$update && isset( $_POST['user_login'] ) )
    43                 $user->user_login = sanitize_user($_POST['user_login'], true);
     45        if ( !$update && isset( $post_data['user_login'] ) )
     46                $user->user_login = sanitize_user($post_data['user_login'], true);
    4447
    4548        $pass1 = $pass2 = '';
    46         if ( isset( $_POST['pass1'] ))
    47                 $pass1 = $_POST['pass1'];
    48         if ( isset( $_POST['pass2'] ))
    49                 $pass2 = $_POST['pass2'];
     49        if ( isset( $post_data['pass1'] ))
     50                $pass1 = $post_data['pass1'];
     51        if ( isset( $post_data['pass2'] ))
     52                $pass2 = $post_data['pass2'];
    5053
    51         if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) {
    52                 $new_role = sanitize_text_field( $_POST['role'] );
     54        if ( isset( $post_data['role'] ) && current_user_can( 'edit_users' ) ) {
     55                $new_role = sanitize_text_field( $post_data['role'] );
    5356                $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false;
    5457                // Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
    5558                // Multisite super admins can freely edit their blog roles -- they possess all caps.
     
    6265                        wp_die(__('You can&#8217;t give users that role.'));
    6366        }
    6467
    65         if ( isset( $_POST['email'] ))
    66                 $user->user_email = sanitize_text_field( $_POST['email'] );
    67         if ( isset( $_POST['url'] ) ) {
    68                 if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) {
     68        if ( isset( $post_data['email'] ))
     69                $user->user_email = sanitize_text_field( $post_data['email'] );
     70        if ( isset( $post_data['url'] ) ) {
     71                if ( empty ( $post_data['url'] ) || $post_data['url'] == 'http://' ) {
    6972                        $user->user_url = '';
    7073                } else {
    71                         $user->user_url = esc_url_raw( $_POST['url'] );
     74                        $user->user_url = esc_url_raw( $post_data['url'] );
    7275                        $protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) );
    7376                        $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
    7477                }
    7578        }
    76         if ( isset( $_POST['first_name'] ) )
    77                 $user->first_name = sanitize_text_field( $_POST['first_name'] );
    78         if ( isset( $_POST['last_name'] ) )
    79                 $user->last_name = sanitize_text_field( $_POST['last_name'] );
    80         if ( isset( $_POST['nickname'] ) )
    81                 $user->nickname = sanitize_text_field( $_POST['nickname'] );
    82         if ( isset( $_POST['display_name'] ) )
    83                 $user->display_name = sanitize_text_field( $_POST['display_name'] );
     79        if ( isset( $post_data['first_name'] ) )
     80                $user->first_name = sanitize_text_field( $post_data['first_name'] );
     81        if ( isset( $post_data['last_name'] ) )
     82                $user->last_name = sanitize_text_field( $post_data['last_name'] );
     83        if ( isset( $post_data['nickname'] ) )
     84                $user->nickname = sanitize_text_field( $post_data['nickname'] );
     85        if ( isset( $post_data['display_name'] ) )
     86                $user->display_name = sanitize_text_field( $post_data['display_name'] );
    8487
    85         if ( isset( $_POST['description'] ) )
    86                 $user->description = trim( $_POST['description'] );
     88        if ( isset( $post_data['description'] ) )
     89                $user->description = trim( $post_data['description'] );
    8790
    8891        foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) {
    89                 if ( isset( $_POST[$method] ))
    90                         $user->$method = sanitize_text_field( $_POST[$method] );
     92                if ( isset( $post_data[$method] ))
     93                        $user->$method = sanitize_text_field( $post_data[$method] );
    9194        }
    9295
    9396        if ( $update ) {
    94                 $user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
    95                 $user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
    96                 $user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
     97                $user->rich_editing = isset( $post_data['rich_editing'] ) && 'false' == $post_data['rich_editing'] ? 'false' : 'true';
     98                $user->admin_color = isset( $post_data['admin_color'] ) ? sanitize_text_field( $post_data['admin_color'] ) : 'fresh';
     99                $user->show_admin_bar_front = isset( $post_data['admin_bar_front'] ) ? 'true' : 'false';
    97100        }
    98101
    99         $user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
     102        $user->comment_shortcuts = isset( $post_data['comment_shortcuts'] ) && 'true' == $post_data['comment_shortcuts'] ? 'true' : '';
    100103
    101104        $user->use_ssl = 0;
    102         if ( !empty($_POST['use_ssl']) )
     105        if ( !empty($post_data['use_ssl']) )
    103106                $user->use_ssl = 1;
    104107
    105108        $errors = new WP_Error();
     
    134137        if ( !empty( $pass1 ) )
    135138                $user->user_pass = $pass1;
    136139
    137         if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) )
     140        if ( !$update && isset( $post_data['user_login'] ) && !validate_username( $post_data['user_login'] ) )
    138141                $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ));
    139142
    140143        if ( !$update && username_exists( $user->user_login ) )
     
    159162                $user_id = wp_update_user( $user );
    160163        } else {
    161164                $user_id = wp_insert_user( $user );
    162                 wp_new_user_notification( $user_id, isset($_POST['send_password']) ? $pass1 : '' );
     165                wp_new_user_notification( $user_id, isset($post_data['send_password']) ? $pass1 : '' );
    163166        }
    164167        return $user_id;
    165168}
  • wp-admin/includes/media.php

     
    444444        }
    445445
    446446        if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
     447                $attachment = stripslashes_deep( $attachment );
     448       
    447449                $post = $_post = get_post($attachment_id, ARRAY_A);
    448450                $post_type_object = get_post_type_object( $post[ 'post_type' ] );
    449451
     
    468470
    469471                if ( isset($attachment['image_alt']) ) {
    470472                        $image_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
    471                         if ( $image_alt != stripslashes($attachment['image_alt']) ) {
    472                                 $image_alt = wp_strip_all_tags( stripslashes($attachment['image_alt']), true );
    473                                 // update_meta expects slashed
    474                                 update_post_meta( $attachment_id, '_wp_attachment_image_alt', addslashes($image_alt) );
     473                        if ( $image_alt != $attachment['image_alt'] ) {
     474                                $image_alt = wp_strip_all_tags( $attachment['image_alt'], true );
     475                                wp_update_post_meta( $attachment_id, '_wp_attachment_image_alt', $image_alt );
    475476                        }
    476477                }
    477478
  • wp-admin/edit-tags.php

     
    4747        if ( !current_user_can( $tax->cap->edit_terms ) )
    4848                wp_die( __( 'Cheatin&#8217; uh?' ) );
    4949
    50         $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
     50        $post_data = wp_unslash( $_POST );
     51
     52        $ret = wp_insert_term( $post_data['tag-name'], $taxonomy, $post_data );
    5153        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
    5254        if ( 'post' != $post_type )
    5355                $location .= '&post_type=' . $post_type;
     
    132134break;
    133135
    134136case 'editedtag':
    135         $tag_ID = (int) $_POST['tag_ID'];
     137
     138        $post_data = wp_unslash( $_POST );
     139
     140        $tag_ID = (int) $post_data['tag_ID'];
    136141        check_admin_referer( 'update-tag_' . $tag_ID );
    137142
    138143        if ( !current_user_can( $tax->cap->edit_terms ) )
     
    142147        if ( ! $tag )
    143148                wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
    144149
    145         $ret = wp_update_term( $tag_ID, $taxonomy, $_POST );
     150        $ret = wp_update_term( $tag_ID, $taxonomy, $post_data );
    146151
    147152        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
    148153        if ( 'post' != $post_type )
     
    164169
    165170default:
    166171if ( ! empty($_REQUEST['_wp_http_referer']) ) {
    167         $location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) );
     172        $location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) );
    168173
    169174        if ( ! empty( $_REQUEST['paged'] ) )
    170175                $location = add_query_arg( 'paged', (int) $_REQUEST['paged'] );
     
    264269<div class="wrap nosubsub">
    265270<?php screen_icon(); ?>
    266271<h2><?php echo esc_html( $title );
    267 if ( !empty($_REQUEST['s']) )
    268         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
     272if ( ! empty($_REQUEST['s']) )
     273        printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) ); ?>
    269274</h2>
    270275
    271276<?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?>
  • wp-admin/admin.php

     
    4343        do_action('after_db_upgrade');
    4444} elseif ( get_option('db_version') != $wp_db_version && empty($_POST) ) {
    4545        if ( !is_multisite() ) {
    46                 wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI']))));
     46                wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
    4747                exit;
    4848        } elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
    4949                /**
     
    8484$editing = false;
    8585
    8686if ( isset($_GET['page']) ) {
    87         $plugin_page = stripslashes($_GET['page']);
     87        $plugin_page = wp_unslash( $_GET['page'] );
    8888        $plugin_page = plugin_basename($plugin_page);
    8989}
    9090
  • wp-admin/custom-header.php

     
    948948                                'width'         => $choice['width'],
    949949                        );
    950950
    951                         update_post_meta( $choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet() );
     951                        wp_update_post_meta( $choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet() );
    952952                        set_theme_mod( 'header_image', $choice['url'] );
    953953                        set_theme_mod( 'header_image_data', $header_image_data );
    954954                        return;
  • wp-admin/media.php

     
    3232                }
    3333                if ( false !== strpos($location, 'upload.php') ) {
    3434                        $location = remove_query_arg('message', $location);
    35                         $location = add_query_arg('posted',     $attachment_id, $location);
     35                        $location = add_query_arg('posted', $attachment_id, $location);
    3636                } elseif ( false !== strpos($location, 'media.php') ) {
    3737                        $location = add_query_arg('message', 'updated', $location);
    3838                }
  • wp-admin/nav-menus.php

     
    9393                                                if ( ! is_wp_error( $parent_object ) ) {
    9494                                                        $parent_data = (array) $parent_object;
    9595                                                        $menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent'];
    96                                                         update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
     96                                                        wp_update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
    9797
    9898                                                }
    9999
     
    103103                                                $menu_item_data['menu_order'] = $menu_item_data['menu_order'] + 1;
    104104
    105105                                                $menu_item_data['menu_item_parent'] = $next_item_data['ID'];
    106                                                 update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
     106                                                wp_update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
    107107
    108108                                                wp_update_post($menu_item_data);
    109109                                                wp_update_post($next_item_data);
     
    115115                                        in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids )
    116116                                ) {
    117117                                        $menu_item_data['menu_item_parent'] = (int) get_post_meta( $menu_item_data['menu_item_parent'], '_menu_item_menu_item_parent', true);
    118                                         update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
     118                                        wp_update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
    119119                                }
    120120                        }
    121121                }
     
    190190                                                        $menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1;
    191191
    192192                                                        // save changes
    193                                                         update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
     193                                                        wp_update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
    194194                                                        wp_update_post($menu_item_data);
    195195                                                        wp_update_post($parent_data);
    196196                                                }
     
    205205                                        ) {
    206206                                                // just make it a child of the previous; keep the order
    207207                                                $menu_item_data['menu_item_parent'] = (int) $orders_to_dbids[$dbids_to_orders[$menu_item_id] - 1];
    208                                                 update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
     208                                                wp_update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
    209209                                                wp_update_post($menu_item_data);
    210210                                        }
    211211                                }
  • wp-admin/edit.php

     
    138138        wp_redirect($sendback);
    139139        exit();
    140140} elseif ( ! empty($_REQUEST['_wp_http_referer']) ) {
    141          wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
     141         wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
    142142         exit;
    143143}
    144144
  • wp-admin/install.php

     
    8484        if ( ! empty( $_POST ) )
    8585                $blog_public = isset( $_POST['blog_public'] );
    8686
    87         $weblog_title = isset( $_POST['weblog_title'] ) ? trim( stripslashes( $_POST['weblog_title'] ) ) : '';
    88         $user_name = isset($_POST['user_name']) ? trim( stripslashes( $_POST['user_name'] ) ) : 'admin';
    89         $admin_password = isset($_POST['admin_password']) ? trim( stripslashes( $_POST['admin_password'] ) ) : '';
    90         $admin_email  = isset( $_POST['admin_email']  ) ? trim( stripslashes( $_POST['admin_email'] ) ) : '';
     87        $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
     88        $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : 'admin';
     89        $admin_password = isset($_POST['admin_password']) ? trim( wp_unslash( $_POST['admin_password'] ) ) : '';
     90        $admin_email  = isset( $_POST['admin_email']  ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';
    9191
    9292        if ( ! is_null( $error ) ) {
    9393?>
  • wp-admin/custom-background.php

     
    378378
    379379                // Add the meta-data
    380380                wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
    381                 update_post_meta( $id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) );
     381                wp_update_post_meta( $id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) );
    382382
    383383                set_theme_mod('background_image', esc_url_raw($url));
    384384
     
    415415                if ( in_array( $_POST['size'], $sizes ) )
    416416                        $size = esc_attr( $_POST['size'] );
    417417
    418                 update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) );
     418                wp_update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) );
    419419                $url = wp_get_attachment_image_src( $attachment_id, $size );
    420420                $thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
    421421                set_theme_mod( 'background_image', esc_url_raw( $url[0] ) );