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