Changeset 23416 for trunk/wp-admin/includes/ajax-actions.php
- Timestamp:
- 02/14/2013 10:51:06 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/includes/ajax-actions.php (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ajax-actions.php
r23382 r23416 60 60 } 61 61 62 $s = stripslashes( $_GET['q'] );62 $s = wp_unslash( $_GET['q'] ); 63 63 64 64 $comma = _x( ',', 'tag delimiter' ); … … 280 280 281 281 function _wp_ajax_add_hierarchical_term() { 282 $action = $_POST['action']; 282 $post_data = wp_unslash( $_POST ); 283 284 $action = $post_data['action']; 283 285 $taxonomy = get_taxonomy(substr($action, 4)); 284 286 check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name ); 285 287 if ( !current_user_can( $taxonomy->cap->edit_terms ) ) 286 288 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; 289 291 if ( 0 > $parent ) 290 292 $parent = 0; 291 293 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(); 293 295 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(); 295 297 $checked_categories = array_map( 'absint', (array) $post_category ); 296 298 $popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false); … … 560 562 if ( !current_user_can( 'manage_categories' ) ) 561 563 wp_die( -1 ); 562 $names = explode( ',', $_POST['newcat']);564 $names = explode( ',', wp_unslash( $_POST['newcat'] ) ); 563 565 $x = new WP_Ajax_Response(); 564 566 foreach ( $names as $cat_name ) { … … 573 575 else if ( is_array( $cat_id ) ) 574 576 $cat_id = $cat_id['term_id']; 575 $cat_name = esc_html( stripslashes($cat_name));577 $cat_name = esc_html( wp_unslash( $cat_name ) ); 576 578 $x->add( array( 577 579 'what' => 'link-category', … … 587 589 global $wp_list_table; 588 590 591 $post_data = wp_unslash( $_POST ); 592 589 593 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'; 592 596 $tax = get_taxonomy($taxonomy); 593 597 … … 597 601 $x = new WP_Ajax_Response(); 598 602 599 $tag = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST);603 $tag = wp_insert_term( $post_data['tag-name'], $taxonomy, $post_data ); 600 604 601 605 if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) { … … 611 615 } 612 616 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'] ) ); 614 618 615 619 $level = 0; … … 729 733 if ( $user->exists() ) { 730 734 $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'] ) ); 735 739 if ( current_user_can( 'unfiltered_html' ) ) { 736 740 if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { … … 958 962 } else { // Update? 959 963 $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'] ); 962 966 if ( '' == trim($key) ) 963 967 wp_die( __( 'Please provide a custom field name.' ) ); … … 1228 1232 1229 1233 if ( isset( $_POST['search'] ) ) 1230 $args['s'] = stripslashes( $_POST['search'] );1234 $args['s'] = wp_unslash( $_POST['search'] ); 1231 1235 $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; 1232 1236 … … 1329 1333 1330 1334 $post = get_post( $post_ID, ARRAY_A ); 1331 $post = add_magic_quotes($post); //since it is from db1332 1335 1333 1336 $data['content'] = $post['post_content']; … … 1377 1380 1378 1381 check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' ); 1379 1380 $taxonomy = sanitize_key( $_POST['taxonomy'] ); 1382 1383 $post_data = wp_unslash( $_POST ); 1384 1385 $taxonomy = sanitize_key( $post_data['taxonomy'] ); 1381 1386 $tax = get_taxonomy( $taxonomy ); 1382 1387 if ( ! $tax ) … … 1388 1393 $wp_list_table = _get_list_table( 'WP_Terms_List_Table', array( 'screen' => 'edit-' . $taxonomy ) ); 1389 1394 1390 if ( ! isset($ _POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )1395 if ( ! isset($post_data['tax_ID']) || ! ( $id = (int) $post_data['tax_ID'] ) ) 1391 1396 wp_die( -1 ); 1392 1397 1393 1398 $tag = get_term( $id, $taxonomy ); 1394 $ _POST['description'] = $tag->description;1395 1396 $updated = wp_update_term($id, $taxonomy, $ _POST);1399 $post_data['description'] = $tag->description; 1400 1401 $updated = wp_update_term($id, $taxonomy, $post_data ); 1397 1402 if ( $updated && !is_wp_error($updated) ) { 1398 1403 $tag = get_term( $updated['term_id'], $taxonomy ); … … 1426 1431 unset( $post_types['attachment'] ); 1427 1432 1428 $s = stripslashes( $_POST['ps'] );1433 $s = wp_unslash( $_POST['ps'] ); 1429 1434 $searchand = $search = ''; 1430 1435 $args = array( … … 1597 1602 } 1598 1603 1599 $post_data = isset( $_REQUEST['post_data'] ) ? $_REQUEST['post_data']: array();1604 $post_data = isset( $_REQUEST['post_data'] ) ? wp_unslash( $_REQUEST['post_data'] ) : array(); 1600 1605 1601 1606 // If the context is custom header or background, make sure the uploaded file is an image. … … 1631 1636 if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) { 1632 1637 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'] ); 1634 1639 1635 1640 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'] ); 1637 1642 } 1638 1643 … … 1779 1784 1780 1785 $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 ) ); 1782 1787 wp_die( 1 ); 1783 1788 } … … 1874 1879 wp_send_json_error(); 1875 1880 1876 $changes = $_REQUEST['changes'];1881 $changes = wp_unslash( $_REQUEST['changes'] ); 1877 1882 $post = get_post( $id, ARRAY_A ); 1878 1883 … … 1891 1896 if ( isset( $changes['alt'] ) ) { 1892 1897 $alt = get_post_meta( $id, '_wp_attachment_image_alt', true ); 1893 $new_alt = stripslashes( $changes['alt'] );1898 $new_alt = $changes['alt']; 1894 1899 if ( $alt != $new_alt ) { 1895 1900 $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 ); 1897 1902 } 1898 1903 } … … 1916 1921 if ( empty( $_REQUEST['attachments'] ) || empty( $_REQUEST['attachments'][ $id ] ) ) 1917 1922 wp_send_json_error(); 1918 $attachment_data = $_REQUEST['attachments'][ $id ];1923 $attachment_data = wp_unslash( $_REQUEST['attachments'][ $id ] ); 1919 1924 1920 1925 check_ajax_referer( 'update-post_' . $id, 'nonce' ); … … 1960 1965 check_ajax_referer( 'update-post_' . $post_id, 'nonce' ); 1961 1966 1962 $attachments = $_REQUEST['attachments'];1967 $attachments = wp_unslash( $_REQUEST['attachments'] ); 1963 1968 1964 1969 if ( ! current_user_can( 'edit_post', $post_id ) ) … … 1991 1996 check_ajax_referer( 'media-send-to-editor', 'nonce' ); 1992 1997 1993 $attachment = stripslashes_deep( $_POST['attachment'] );1998 $attachment = wp_unslash( $_POST['attachment'] ); 1994 1999 1995 2000 $id = intval( $attachment['id'] ); … … 2046 2051 check_ajax_referer( 'media-send-to-editor', 'nonce' ); 2047 2052 2048 if ( ! $src = stripslashes( $_POST['src'] ) )2053 if ( ! $src = wp_unslash( $_POST['src'] ) ) 2049 2054 wp_send_json_error(); 2050 2055 … … 2055 2060 wp_send_json_error(); 2056 2061 2057 if ( ! $title = trim( stripslashes( $_POST['title'] ) ) )2062 if ( ! $title = trim( wp_unslash( $_POST['title'] ) ) ) 2058 2063 $title = wp_basename( $src ); 2059 2064 … … 2084 2089 2085 2090 if ( ! empty($_POST['data']) ) { 2086 $data = (array) $_POST['data'];2091 $data = wp_unslash( (array) $_POST['data'] ); 2087 2092 // todo: how much to sanitize and preset and what to leave to be accessed from $data or $_POST..? 2088 2093 $user = wp_get_current_user();
Note: See TracChangeset
for help on using the changeset viewer.