Ticket #21767: 21767.diff
File 21767.diff, 52.0 KB (added by , 11 years ago) |
---|
-
wp-comments-post.php
47 47 do_action('pre_comment_on_post', $comment_post_ID); 48 48 } 49 49 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;50 $comment_author = ( isset($_POST['author']) ) ? trim(strip_tags(stripslashes($_POST['author']))) : null; 51 $comment_author_email = ( isset($_POST['email']) ) ? trim(stripslashes($_POST['email'])) : null; 52 $comment_author_url = ( isset($_POST['url']) ) ? trim(stripslashes($_POST['url'])) : null; 53 $comment_content = ( isset($_POST['comment']) ) ? trim(stripslashes($_POST['comment'])) : null; 54 54 55 55 // If the user is logged in 56 56 $user = wp_get_current_user(); -
wp-includes/default-filters.php
14 14 15 15 // Strip, trim, kses, special chars for string saves 16 16 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 ) { 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' ); 19 19 add_filter( $filter, '_wp_specialchars', 30 ); 20 20 } 21 21 … … 31 31 32 32 // Kses only for textarea saves 33 33 foreach ( 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' ); 35 35 } 36 36 37 37 // Kses only for textarea admin displays 38 38 if ( 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 ) { 40 40 add_filter( $filter, 'wp_kses_data' ); 41 41 } 42 add_filter( 'comment_text', 'wp_kses_post' );43 42 } 44 43 45 44 // Email saves 46 45 foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) { 47 46 add_filter( $filter, 'trim' ); 48 47 add_filter( $filter, 'sanitize_email' ); 49 add_filter( $filter, 'wp_ filter_kses' );48 add_filter( $filter, 'wp_kses_data' ); 50 49 } 51 50 52 51 // Email admin display -
wp-includes/taxonomy.php
2061 2061 $args = sanitize_term($args, $taxonomy, 'db'); 2062 2062 extract($args, EXTR_SKIP); 2063 2063 2064 // expected_slashed ($name)2065 $name = stripslashes($name);2066 $description = stripslashes($description);2067 2068 2064 if ( empty($slug) ) 2069 2065 $slug = sanitize_title($name); 2070 2066 … … 2360 2356 if ( is_wp_error( $term ) ) 2361 2357 return $term; 2362 2358 2363 // Escape data pulled from DB.2364 $term = add_magic_quotes($term);2365 2366 2359 // Merge old and new args with new args overwriting old ones. 2367 2360 $args = array_merge($term, $args); 2368 2361 … … 2371 2364 $args = sanitize_term($args, $taxonomy, 'db'); 2372 2365 extract($args, EXTR_SKIP); 2373 2366 2374 // expected_slashed ($name)2375 $name = stripslashes($name);2376 $description = stripslashes($description);2377 2378 2367 if ( '' == trim($name) ) 2379 2368 return new WP_Error('empty_term_name', __('A name is required for this term')); 2380 2369 -
wp-includes/post.php
1742 1742 * @link http://codex.wordpress.org/Function_Reference/add_post_meta 1743 1743 * 1744 1744 * @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). 1747 1747 * @param bool $unique Optional, default is false. Whether the same key should not be added. 1748 1748 * @return bool False for failure. True for success. 1749 1749 */ 1750 1750 function 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.5.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 */ 1774 function wp_add_post_meta($post_id, $meta_key, $meta_value, $unique = false) { 1751 1775 // make sure meta is added to the post, not a revision 1752 1776 if ( $the_post = wp_is_post_revision($post_id) ) 1753 1777 $post_id = $the_post; … … 1809 1833 * @link http://codex.wordpress.org/Function_Reference/update_post_meta 1810 1834 * 1811 1835 * @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). 1814 1838 * @param mixed $prev_value Optional. Previous value to check before removing. 1815 1839 * @return bool False on failure, true if success. 1816 1840 */ 1817 1841 function 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.5.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 */ 1869 function wp_update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') { 1818 1870 // make sure meta is added to the post, not a revision 1819 1871 if ( $the_post = wp_is_post_revision($post_id) ) 1820 1872 $post_id = $the_post; … … 2406 2458 2407 2459 do_action('wp_trash_post', $post_id); 2408 2460 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()); 2411 2463 2412 2464 $post['post_status'] = 'trash'; 2413 2465 wp_insert_post($post); … … 2483 2535 $statuses = array(); 2484 2536 foreach ( $comments as $comment ) 2485 2537 $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); 2487 2539 2488 2540 // Set status for all comments to post-trashed 2489 2541 $result = $wpdb->update($wpdb->comments, array('comment_approved' => 'post-trashed'), array('comment_post_ID' => $post_id)); … … 2859 2911 2860 2912 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); 2861 2913 2862 // expected_slashed (everything!)2863 2914 $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' ) ); 2864 2915 $data = apply_filters('wp_insert_post_data', $data, $postarr); 2865 $data = stripslashes_deep( $data );2866 2916 $where = array( 'ID' => $post_ID ); 2867 2917 2868 2918 if ( $update ) { … … 2936 2986 else 2937 2987 return 0; 2938 2988 } 2939 update_post_meta($post_ID, '_wp_page_template', $page_template);2989 wp_update_post_meta($post_ID, '_wp_page_template', $page_template); 2940 2990 } 2941 2991 2942 2992 wp_transition_post_status($data['post_status'], $previous_status, $post); … … 2969 3019 if ( is_object($postarr) ) { 2970 3020 // non-escaped post was passed 2971 3021 $postarr = get_object_vars($postarr); 2972 $postarr = add_magic_quotes($postarr);2973 3022 } 2974 3023 2975 3024 // First, get all of the original fields 2976 3025 $post = get_post($postarr['ID'], ARRAY_A); 2977 3026 2978 // Escape data pulled from DB.2979 $post = add_magic_quotes($post);2980 2981 3027 // Passed post category list overwrites existing category list if not empty. 2982 3028 if ( isset($postarr['post_category']) && is_array($postarr['post_category']) 2983 3029 && 0 != count($postarr['post_category']) ) … … 3960 4006 else 3961 4007 $post_name = sanitize_title($post_name); 3962 4008 3963 // expected_slashed ($post_name)3964 4009 $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent); 3965 4010 3966 4011 if ( empty($post_date) ) … … 4003 4048 if ( ! isset($pinged) ) 4004 4049 $pinged = ''; 4005 4050 4006 // expected_slashed (everything!)4007 4051 $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' ) ); 4008 $data = stripslashes_deep( $data );4009 4052 4010 4053 if ( $update ) { 4011 4054 $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) ); … … 4050 4093 clean_post_cache( $post_ID ); 4051 4094 4052 4095 if ( ! empty( $context ) ) 4053 add_post_meta( $post_ID, '_wp_attachment_context', $context, true );4096 wp_add_post_meta( $post_ID, '_wp_attachment_context', $context, true ); 4054 4097 4055 4098 if ( $update) { 4056 4099 do_action('edit_attachment', $post_ID); … … 4437 4480 4438 4481 // if we haven't added this old slug before, add it now 4439 4482 if ( !empty( $post_before->post_name ) && !in_array($post_before->post_name, $old_slugs) ) 4440 add_post_meta($post_id, '_wp_old_slug', $post_before->post_name);4483 wp_add_post_meta($post_id, '_wp_old_slug', $post_before->post_name); 4441 4484 4442 4485 // if the new slug was used previously, delete it from the list 4443 4486 if ( in_array($post->post_name, $old_slugs) ) … … 4862 4905 return; 4863 4906 4864 4907 if ( get_option('default_pingback_flag') ) 4865 add_post_meta( $post_id, '_pingme', '1' );4866 add_post_meta( $post_id, '_encloseme', '1' );4908 wp_add_post_meta( $post_id, '_pingme', '1' ); 4909 wp_add_post_meta( $post_id, '_encloseme', '1' ); 4867 4910 4868 4911 wp_schedule_single_event(time(), 'do_pings'); 4869 4912 } … … 5089 5132 return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) ); 5090 5133 5091 5134 $post = _wp_post_revision_fields( $post, $autosave ); 5092 $post = add_magic_quotes($post); //since data is from db5093 5135 5094 5136 $revision_id = wp_insert_post( $post ); 5095 5137 if ( is_wp_error($revision_id) ) … … 5168 5210 5169 5211 $update['ID'] = $revision['post_parent']; 5170 5212 5171 $update = add_magic_quotes( $update ); //since data is from db5172 5173 5213 $post_id = wp_update_post( $update ); 5174 5214 if ( is_wp_error( $post_id ) ) 5175 5215 return $post_id; … … 5391 5431 $thumbnail_id = absint( $thumbnail_id ); 5392 5432 if ( $post && $thumbnail_id && get_post( $thumbnail_id ) ) { 5393 5433 if ( $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) ) 5394 return update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id );5434 return wp_update_post_meta( $post->ID, '_thumbnail_id', $thumbnail_id ); 5395 5435 else 5396 5436 return delete_post_meta( $post->ID, '_thumbnail_id' ); 5397 5437 } -
wp-includes/comment.php
631 631 */ 632 632 function sanitize_comment_cookies() { 633 633 if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { 634 $comment_author = apply_filters('pre_comment_author_name',$_COOKIE['comment_author_'.COOKIEHASH]);635 $comment_author = stripslashes($comment_author);634 $comment_author = stripslashes($_COOKIE['comment_author_'.COOKIEHASH]); 635 $comment_author = apply_filters('pre_comment_author_name', $comment_author); 636 636 $comment_author = esc_attr($comment_author); 637 637 $_COOKIE['comment_author_'.COOKIEHASH] = $comment_author; 638 638 } 639 639 640 640 if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) { 641 $comment_author_email = apply_filters('pre_comment_author_email',$_COOKIE['comment_author_email_'.COOKIEHASH]);642 $comment_author_email = stripslashes($comment_author_email);641 $comment_author_email = stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH]); 642 $comment_author_email = apply_filters('pre_comment_author_email', $comment_author_email); 643 643 $comment_author_email = esc_attr($comment_author_email); 644 644 $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email; 645 645 } 646 646 647 647 if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) { 648 $comment_author_url = apply_filters('pre_comment_author_url',$_COOKIE['comment_author_url_'.COOKIEHASH]);649 $comment_author_url = stripslashes($comment_author_url);648 $comment_author_url = stripslashes($_COOKIE['comment_author_url_'.COOKIEHASH]); 649 $comment_author_url = apply_filters('pre_comment_author_url', $comment_author_url); 650 650 $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url; 651 651 } 652 652 } … … 668 668 extract($commentdata, EXTR_SKIP); 669 669 670 670 // Simple duplicate check 671 // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) 672 $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' "; 671 $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 ); 673 672 if ( $comment_author_email ) 674 $dupe .= "OR comment_author_email = '$comment_author_email' ";675 $dupe .= ") AND comment_content = '$comment_content' LIMIT 1";673 $dupe .= $wpdb->prepare( "OR comment_author_email = %s ", $comment_author_email ); 674 $dupe .= $wpdb->prepare( ") AND comment_content = %s LIMIT 1", $comment_content ); 676 675 if ( $wpdb->get_var($dupe) ) { 677 676 do_action( 'comment_duplicate_trigger', $commentdata ); 678 677 if ( defined('DOING_AJAX') ) … … 1260 1259 */ 1261 1260 function wp_insert_comment($commentdata) { 1262 1261 global $wpdb; 1263 extract( stripslashes_deep($commentdata), EXTR_SKIP);1262 extract($commentdata, EXTR_SKIP); 1264 1263 1265 1264 if ( ! isset($comment_author_IP) ) 1266 1265 $comment_author_IP = ''; … … 1505 1504 $commentarr = wp_filter_comment( $commentarr ); 1506 1505 1507 1506 // Now extract the merged array. 1508 extract( stripslashes_deep($commentarr), EXTR_SKIP);1507 extract($commentarr, EXTR_SKIP); 1509 1508 1510 1509 $comment_content = apply_filters('comment_save_pre', $comment_content); 1511 1510 -
wp-includes/functions.php
468 468 } 469 469 470 470 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" ); 472 472 } 473 473 } 474 474 } -
wp-includes/user.php
1390 1390 } 1391 1391 1392 1392 $data = compact( 'user_pass', 'user_email', 'user_url', 'user_nicename', 'display_name', 'user_registered' ); 1393 $data = stripslashes_deep( $data );1394 1393 1395 1394 if ( $update ) { 1396 1395 $wpdb->update( $wpdb->users, $data, compact( 'ID' ) ); … … 1462 1461 $user[ $key ] = get_user_meta( $ID, $key, true ); 1463 1462 } 1464 1463 1465 // Escape data pulled from DB.1466 $user = add_magic_quotes( $user );1467 1468 1464 // If password is changing, hash it now. 1469 1465 if ( ! empty($userdata['user_pass']) ) { 1470 1466 $plaintext_pass = $userdata['user_pass']; -
wp-includes/class-wp-xmlrpc-server.php
276 276 $post_id = (int) $post_id; 277 277 278 278 foreach ( (array) $fields as $meta ) { 279 $meta['key'] = stripslashes( $meta['key'] ); 280 $meta['value'] = stripslashes_deep( $meta['value'] ); 279 281 if ( isset($meta['id']) ) { 280 282 $meta['id'] = (int) $meta['id']; 281 283 $pmeta = get_metadata_by_mid( 'post', $meta['id'] ); 282 284 if ( isset($meta['key']) ) { 283 $meta['key'] = stripslashes( $meta['key'] );284 285 if ( $meta['key'] != $pmeta->meta_key ) 285 286 continue; 286 $meta['value'] = stripslashes_deep( $meta['value'] );287 287 if ( current_user_can( 'edit_post_meta', $post_id, $meta['key'] ) ) 288 288 update_metadata_by_mid( 'post', $meta['id'], $meta['value'] ); 289 289 } elseif ( current_user_can( 'delete_post_meta', $post_id, $pmeta->meta_key ) ) { 290 290 delete_metadata_by_mid( 'post', $meta['id'] ); 291 291 } 292 292 } 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'] ); 294 294 } 295 295 } 296 296 } … … 4316 4316 } 4317 4317 } 4318 4318 if (!$found) 4319 add_post_meta( $post_ID, 'enclosure', $encstring );4319 wp_add_post_meta( $post_ID, 'enclosure', $encstring ); 4320 4320 } 4321 4321 } 4322 4322 … … 5274 5274 // retain old cats 5275 5275 $cats = wp_get_post_categories($post_ID); 5276 5276 $postdata['post_category'] = $cats; 5277 $this->escape($postdata);5278 5277 5279 5278 $result = wp_update_post($postdata); 5280 5279 -
wp-includes/formatting.php
1691 1691 * @return string Converted content. 1692 1692 */ 1693 1693 function wp_rel_nofollow( $text ) { 1694 // This is a pre save filter, so text is already escaped.1695 $text = stripslashes($text);1696 1694 $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text); 1697 $text = esc_sql($text);1698 1695 return $text; 1699 1696 } 1700 1697 -
wp-includes/kses.php
1326 1326 */ 1327 1327 function kses_init_filters() { 1328 1328 // Normal filtering 1329 add_filter('title_save_pre', 'wp_ filter_kses');1329 add_filter('title_save_pre', 'wp_kses_data'); 1330 1330 1331 1331 // Comment filtering 1332 1332 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' ); 1334 1334 else 1335 add_filter( 'pre_comment_content', 'wp_ filter_kses' );1335 add_filter( 'pre_comment_content', 'wp_kses_data' ); 1336 1336 1337 1337 // 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'); 1341 1341 } 1342 1342 1343 1343 /** … … 1354 1354 */ 1355 1355 function kses_remove_filters() { 1356 1356 // Normal filtering 1357 remove_filter('title_save_pre', 'wp_ filter_kses');1357 remove_filter('title_save_pre', 'wp_kses_data'); 1358 1358 1359 1359 // 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' ); 1362 1362 1363 1363 // 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'); 1367 1367 } 1368 1368 1369 1369 /** -
wp-includes/meta.php
42 42 43 43 $column = esc_sql($meta_type . '_id'); 44 44 45 // expected_slashed ($meta_key)46 $meta_key = stripslashes($meta_key);47 $meta_value = stripslashes_deep($meta_value);48 45 $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); 49 46 50 47 $check = apply_filters( "add_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $unique ); … … 113 110 $column = esc_sql($meta_type . '_id'); 114 111 $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; 115 112 116 // expected_slashed ($meta_key)117 $meta_key = stripslashes($meta_key);118 113 $passed_value = $meta_value; 119 $meta_value = stripslashes_deep($meta_value);120 114 $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); 121 115 122 116 $check = apply_filters( "update_{$meta_type}_metadata", null, $object_id, $meta_key, $meta_value, $prev_value ); -
wp-includes/nav-menu.php
369 369 370 370 $menu_item_db_id = (int) $menu_item_db_id; 371 371 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']) ); 377 377 378 378 $args['menu-item-classes'] = array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-classes'] ) ); 379 379 $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']) ); 383 383 384 384 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() ); 386 386 elseif ( get_post_meta( $menu_item_db_id, '_menu_item_orphaned' ) ) 387 387 delete_post_meta( $menu_item_db_id, '_menu_item_orphaned' ); 388 388 -
wp-mail.php
202 202 $post_category = array(get_option('default_email_category')); 203 203 204 204 $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);206 205 207 206 $post_ID = wp_insert_post($post_data); 208 207 if ( is_wp_error( $post_ID ) ) -
wp-admin/includes/bookmark.php
39 39 40 40 if ( !empty( $link_id ) ) { 41 41 $_POST['link_id'] = $link_id; 42 return wp_update_link( $_POST);42 return wp_update_link( stripslashes_deep( $_POST ) ); 43 43 } else { 44 return wp_insert_link( $_POST);44 return wp_insert_link( stripslashes_deep( $_POST ) ); 45 45 } 46 46 } 47 47 … … 137 137 $linkdata = wp_parse_args( $linkdata, $defaults ); 138 138 $linkdata = sanitize_bookmark( $linkdata, 'db' ); 139 139 140 extract( stripslashes_deep( $linkdata ), EXTR_SKIP );140 extract( $linkdata, EXTR_SKIP ); 141 141 142 142 $update = false; 143 143 … … 250 250 251 251 $link = get_bookmark( $link_id, ARRAY_A ); 252 252 253 // Escape data pulled from DB.254 $link = add_magic_quotes( $link );255 256 253 // Passed link category list overwrites existing category list if not empty. 257 254 if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) 258 255 && 0 != count( $linkdata['link_category'] ) ) -
wp-admin/includes/taxonomy.php
157 157 // First, get all of the original fields 158 158 $category = get_category($cat_ID, ARRAY_A); 159 159 160 // Escape data pulled from DB.161 $category = add_magic_quotes($category);162 163 160 // Merge old and new fields with new fields overwriting old ones. 164 161 $catarr = array_merge($category, $catarr); 165 162 -
wp-admin/includes/ajax-actions.php
279 279 */ 280 280 281 281 function _wp_ajax_add_hierarchical_term() { 282 $action = $_POST['action']; 282 $post_data = stripslashes_deep( $_POST ); 283 $action = $post_data['action']; 283 284 $taxonomy = get_taxonomy(substr($action, 4)); 284 285 check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name ); 285 286 if ( !current_user_can( $taxonomy->cap->edit_terms ) ) 286 287 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;288 $names = explode(',', $post_data['new'.$taxonomy->name]); 289 $parent = isset($post_data['new'.$taxonomy->name.'_parent']) ? (int) $post_data['new'.$taxonomy->name.'_parent'] : 0; 289 290 if ( 0 > $parent ) 290 291 $parent = 0; 291 292 if ( $taxonomy->name == 'category' ) 292 $post_category = isset( $_POST['post_category']) ? (array) $_POST['post_category'] : array();293 $post_category = isset( $post_data['post_category'] ) ? (array) $post_data['post_category'] : array(); 293 294 else 294 $post_category = ( isset( $_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();295 $post_category = ( isset( $post_data['tax_input'] ) && isset( $post_data['tax_input'][$taxonomy->name] ) ) ? (array) $post_data['tax_input'][$taxonomy->name] : array(); 295 296 $checked_categories = array_map( 'absint', (array) $post_category ); 296 297 $popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false); 297 298 … … 559 560 check_ajax_referer( $action ); 560 561 if ( !current_user_can( 'manage_categories' ) ) 561 562 wp_die( -1 ); 562 $names = explode( ',', $_POST['newcat']);563 $names = explode( ',', stripslashes( $_POST['newcat'] ) ); 563 564 $x = new WP_Ajax_Response(); 564 565 foreach ( $names as $cat_name ) { 565 566 $cat_name = trim($cat_name); … … 586 587 function wp_ajax_add_tag() { 587 588 global $wp_list_table; 588 589 590 $post_data = stripslashes_deep( $_POST ); 591 589 592 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';593 $post_type = !empty($post_data['post_type']) ? $post_data['post_type'] : 'post'; 594 $taxonomy = !empty($post_data['taxonomy']) ? $post_data['taxonomy'] : 'post_tag'; 592 595 $tax = get_taxonomy($taxonomy); 593 596 594 597 if ( !current_user_can( $tax->cap->edit_terms ) ) … … 596 599 597 600 $x = new WP_Ajax_Response(); 598 601 599 $tag = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST);602 $tag = wp_insert_term( $post_data['tag-name'], $taxonomy, $post_data ); 600 603 601 604 if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) { 602 605 $message = __('An error has occurred. Please reload the page and try again.'); … … 610 613 $x->send(); 611 614 } 612 615 613 $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => $_POST['screen']) );616 $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => stripslashes( $_POST['screen'] ) ) ); 614 617 615 618 $level = 0; 616 619 if ( is_taxonomy_hierarchical($taxonomy) ) { … … 731 734 $comment_author = $wpdb->escape($user->display_name); 732 735 $comment_author_email = $wpdb->escape($user->user_email); 733 736 $comment_author_url = $wpdb->escape($user->user_url); 734 $comment_content = trim( $_POST['content']);737 $comment_content = trim( stripslashes( $_POST['content'] ) ); 735 738 if ( current_user_can( 'unfiltered_html' ) ) { 736 739 if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { 737 740 kses_remove_filters(); // start with a clean slate … … 1328 1331 $data = &$_POST; 1329 1332 1330 1333 $post = get_post( $post_ID, ARRAY_A ); 1331 $post = add_magic_quotes($post); //since it is from db1332 1334 1333 1335 $data['content'] = $post['post_content']; 1334 1336 $data['excerpt'] = $post['post_excerpt']; … … 1376 1378 global $wp_list_table; 1377 1379 1378 1380 check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); 1381 1382 $post_data = stripslashes_deep( $_POST ); 1379 1383 1380 $taxonomy = sanitize_key( $ _POST['taxonomy'] );1384 $taxonomy = sanitize_key( $post_data['taxonomy'] ); 1381 1385 $tax = get_taxonomy( $taxonomy ); 1382 1386 if ( ! $tax ) 1383 1387 wp_die( 0 ); … … 1387 1391 1388 1392 $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) ); 1389 1393 1390 if ( ! isset($ _POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )1394 if ( ! isset($post_data['tax_ID']) || ! ( $id = (int) $post_data['tax_ID'] ) ) 1391 1395 wp_die( -1 ); 1392 1396 1393 1397 $tag = get_term( $id, $taxonomy ); 1394 $ _POST['description'] = $tag->description;1398 $post_data['description'] = $tag->description; 1395 1399 1396 $updated = wp_update_term($id, $taxonomy, $ _POST);1400 $updated = wp_update_term($id, $taxonomy, $post_data ); 1397 1401 if ( $updated && !is_wp_error($updated) ) { 1398 1402 $tag = get_term( $updated['term_id'], $taxonomy ); 1399 1403 if ( !$tag || is_wp_error( $tag ) ) { … … 1596 1600 $post_id = null; 1597 1601 } 1598 1602 1599 $post_data = isset( $_REQUEST['post_data'] ) ? $_REQUEST['post_data']: array();1603 $post_data = isset( $_REQUEST['post_data'] ) ? stripslashes_deep( $_REQUEST['post_data'] ) : array(); 1600 1604 1601 1605 // If the context is custom header or background, make sure the uploaded file is an image. 1602 1606 if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) { … … 1630 1634 1631 1635 if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) { 1632 1636 if ( 'custom-background' === $post_data['context'] ) 1633 update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );1637 wp_update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] ); 1634 1638 1635 1639 if ( 'custom-header' === $post_data['context'] ) 1636 update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );1640 wp_update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] ); 1637 1641 } 1638 1642 1639 1643 if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) … … 1778 1782 wp_die( 0 ); 1779 1783 1780 1784 $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 ) );1785 wp_update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) ); 1782 1786 wp_die( 1 ); 1783 1787 } 1784 1788 -
wp-admin/includes/post.php
149 149 */ 150 150 function edit_post( $post_data = null ) { 151 151 152 if ( empty($post_data) ) 153 $post_data = &$_POST; 152 if ( empty($post_data) ) { 153 $post_data = stripslashes_deep( $_POST ); 154 } 154 155 155 156 // Clear out any data in internal vars. 156 157 unset( $post_data['filter'] ); … … 241 242 242 243 add_meta( $post_ID ); 243 244 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 ); 245 246 246 247 wp_update_post( $post_data ); 247 248 … … 559 560 } 560 561 561 562 // Create the post. 562 $post_ID = wp_insert_post( $_POST);563 $post_ID = wp_insert_post( stripslashes_deep( $_POST ) ); 563 564 if ( is_wp_error( $post_ID ) ) 564 565 return $post_ID; 565 566 … … 568 569 569 570 add_meta( $post_ID ); 570 571 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 ); 572 573 573 574 // Now that we have an ID we can fix any attachment anchor hrefs 574 575 _fix_attachment_links( $post_ID ); … … 614 615 615 616 $metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : ''; 616 617 $metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : ''; 617 $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue']: '';618 $metavalue = isset($_POST['metavalue']) ? stripslashes( trim( $_POST['metavalue'] ) ) : ''; 618 619 if ( is_string( $metavalue ) ) 619 620 $metavalue = trim( $metavalue ); 620 621 … … 633 634 634 635 $metakey = esc_sql( $metakey ); 635 636 636 return add_post_meta( $post_ID, $metakey, $metavalue );637 return wp_add_post_meta( $post_ID, $metakey, $metavalue ); 637 638 } 638 639 639 640 return false; … … 706 707 * @since 1.2.0 707 708 * 708 709 * @param unknown_type $meta_id 709 * @param unknown_type $meta_key Expect Slashed710 * @param unknown_type $meta_value Expect Slashed710 * @param unknown_type $meta_key 711 * @param unknown_type $meta_value 711 712 * @return unknown 712 713 */ 713 714 function update_meta( $meta_id, $meta_key, $meta_value ) { 714 $meta_key = stripslashes( $meta_key );715 $meta_value = stripslashes_deep( $meta_value );716 717 715 return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key ); 718 716 } 719 717 … … 767 765 768 766 if ( $replace ) { 769 767 $post['post_content'] = $content; 770 // Escape data pulled from DB.771 $post = add_magic_quotes($post);772 768 773 769 return wp_update_post($post); 774 770 } … … 1179 1175 $now = time(); 1180 1176 $lock = "$now:$user_id"; 1181 1177 1182 update_post_meta( $post->ID, '_edit_lock', $lock );1178 wp_update_post_meta( $post->ID, '_edit_lock', $lock ); 1183 1179 return array( $now, $user_id ); 1184 1180 } 1185 1181 -
wp-admin/includes/misc.php
323 323 324 324 if ( !$user = wp_get_current_user() ) 325 325 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'] ); 328 328 329 329 if ( $option != sanitize_key( $option ) ) 330 330 return; -
wp-admin/includes/comment.php
19 19 function comment_exists($comment_author, $comment_date) { 20 20 global $wpdb; 21 21 22 $comment_author = stripslashes($comment_author);23 $comment_date = stripslashes($comment_date);24 25 22 return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments 26 23 WHERE comment_author = %s AND comment_date = %s", $comment_author, $comment_date) ); 27 24 } … … 33 30 */ 34 31 function edit_comment() { 35 32 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'] ) ) 37 36 wp_die ( __( 'You are not allowed to edit comments on this post.' ) ); 38 37 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']; 45 44 46 45 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] ) { 48 47 $_POST['edit_date'] = '1'; 49 48 break; 50 49 } 51 50 } 52 51 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']; 60 59 $jj = ($jj > 31 ) ? 31 : $jj; 61 60 $hh = ($hh > 23 ) ? $hh -24 : $hh; 62 61 $mn = ($mn > 59 ) ? $mn -60 : $mn; 63 62 $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"; 65 64 } 66 65 67 wp_update_comment( $ _POST);66 wp_update_comment( $post_data ); 68 67 } 69 68 70 69 /** -
wp-admin/includes/image-edit.php
533 533 } 534 534 } 535 535 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) ) { 537 537 $msg->error = __('Cannot save image metadata.'); 538 538 return $msg; 539 539 } … … 699 699 700 700 if ( $success ) { 701 701 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); 703 703 704 704 if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) { 705 705 // Check if it's an image edit from attachment edit screen -
wp-admin/includes/user.php
38 38 } else { 39 39 $update = false; 40 40 } 41 42 // get clean data before we get started. 43 $post_data = stripslashes_deep( $_POST ); 41 44 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); 44 47 45 48 $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']; 50 53 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'] ); 53 56 $potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false; 54 57 // Don't let anyone with 'edit_users' (admins) edit their own role to something without it. 55 58 // Multisite super admins can freely edit their blog roles -- they possess all caps. … … 62 65 wp_die(__('You can’t give users that role.')); 63 66 } 64 67 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://' ) { 69 72 $user->user_url = ''; 70 73 } else { 71 $user->user_url = esc_url_raw( $ _POST['url'] );74 $user->user_url = esc_url_raw( $post_data['url'] ); 72 75 $protocols = implode( '|', array_map( 'preg_quote', wp_allowed_protocols() ) ); 73 76 $user->user_url = preg_match('/^(' . $protocols . '):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url; 74 77 } 75 78 } 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'] ); 84 87 85 if ( isset( $ _POST['description'] ) )86 $user->description = trim( $ _POST['description'] );88 if ( isset( $post_data['description'] ) ) 89 $user->description = trim( $post_data['description'] ); 87 90 88 91 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] ); 91 94 } 92 95 93 96 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'; 97 100 } 98 101 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' : ''; 100 103 101 104 $user->use_ssl = 0; 102 if ( !empty($ _POST['use_ssl']) )105 if ( !empty($post_data['use_ssl']) ) 103 106 $user->use_ssl = 1; 104 107 105 108 $errors = new WP_Error(); … … 134 137 if ( !empty( $pass1 ) ) 135 138 $user->user_pass = $pass1; 136 139 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'] ) ) 138 141 $errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' )); 139 142 140 143 if ( !$update && username_exists( $user->user_login ) ) … … 159 162 $user_id = wp_update_user( $user ); 160 163 } else { 161 164 $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 : '' ); 163 166 } 164 167 return $user_id; 165 168 } -
wp-admin/includes/media.php
444 444 } 445 445 446 446 if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { 447 $attachment = stripslashes_deep( $attachment ); 448 447 449 $post = $_post = get_post($attachment_id, ARRAY_A); 448 450 $post_type_object = get_post_type_object( $post[ 'post_type' ] ); 449 451 … … 468 470 469 471 if ( isset($attachment['image_alt']) ) { 470 472 $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 ); 475 476 } 476 477 } 477 478 -
wp-admin/edit-tags.php
47 47 if ( !current_user_can( $tax->cap->edit_terms ) ) 48 48 wp_die( __( 'Cheatin’ uh?' ) ); 49 49 50 $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); 50 $post_data = stripslashes_deep( $_POST ); 51 52 $ret = wp_insert_term( $post_data['tag-name'], $taxonomy, $post_data ); 51 53 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 52 54 if ( 'post' != $post_type ) 53 55 $location .= '&post_type=' . $post_type; … … 132 134 break; 133 135 134 136 case 'editedtag': 135 $tag_ID = (int) $_POST['tag_ID']; 137 138 $post_data = stripslashes_deep( $_POST ); 139 140 $tag_ID = (int) $post_data['tag_ID']; 136 141 check_admin_referer( 'update-tag_' . $tag_ID ); 137 142 138 143 if ( !current_user_can( $tax->cap->edit_terms ) ) … … 142 147 if ( ! $tag ) 143 148 wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) ); 144 149 145 $ret = wp_update_term( $tag_ID, $taxonomy, $ _POST);150 $ret = wp_update_term( $tag_ID, $taxonomy, $post_data ); 146 151 147 152 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 148 153 if ( 'post' != $post_type ) -
wp-admin/custom-header.php
948 948 'width' => $choice['width'], 949 949 ); 950 950 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() ); 952 952 set_theme_mod( 'header_image', $choice['url'] ); 953 953 set_theme_mod( 'header_image_data', $header_image_data ); 954 954 return; -
wp-admin/media.php
32 32 } 33 33 if ( false !== strpos($location, 'upload.php') ) { 34 34 $location = remove_query_arg('message', $location); 35 $location = add_query_arg('posted', 35 $location = add_query_arg('posted', $attachment_id, $location); 36 36 } elseif ( false !== strpos($location, 'media.php') ) { 37 37 $location = add_query_arg('message', 'updated', $location); 38 38 } -
wp-admin/nav-menus.php
93 93 if ( ! is_wp_error( $parent_object ) ) { 94 94 $parent_data = (array) $parent_object; 95 95 $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'] ); 97 97 98 98 } 99 99 … … 103 103 $menu_item_data['menu_order'] = $menu_item_data['menu_order'] + 1; 104 104 105 105 $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'] ); 107 107 108 108 wp_update_post($menu_item_data); 109 109 wp_update_post($next_item_data); … … 115 115 in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) 116 116 ) { 117 117 $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'] ); 119 119 } 120 120 } 121 121 } … … 190 190 $menu_item_data['menu_order'] = $menu_item_data['menu_order'] - 1; 191 191 192 192 // 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'] ); 194 194 wp_update_post($menu_item_data); 195 195 wp_update_post($parent_data); 196 196 } … … 205 205 ) { 206 206 // just make it a child of the previous; keep the order 207 207 $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'] ); 209 209 wp_update_post($menu_item_data); 210 210 } 211 211 } -
wp-admin/custom-background.php
378 378 379 379 // Add the meta-data 380 380 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' ) ); 382 382 383 383 set_theme_mod('background_image', esc_url_raw($url)); 384 384 … … 415 415 if ( in_array( $_POST['size'], $sizes ) ) 416 416 $size = esc_attr( $_POST['size'] ); 417 417 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' ) ); 419 419 $url = wp_get_attachment_image_src( $attachment_id, $size ); 420 420 $thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' ); 421 421 set_theme_mod( 'background_image', esc_url_raw( $url[0] ) );