Changeset 23554 for trunk/wp-admin/includes/post.php
- Timestamp:
- 03/01/2013 04:28:40 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r23449 r23554 150 150 function edit_post( $post_data = null ) { 151 151 152 if ( empty( $post_data) )153 $post_data = wp_unslash( $_POST );152 if ( empty($post_data) ) 153 $post_data = &$_POST; 154 154 155 155 // Clear out any data in internal vars. … … 237 237 if ( isset( $post_data[ '_wp_attachment_image_alt' ] ) ) { 238 238 $image_alt = get_post_meta( $post_ID, '_wp_attachment_image_alt', true ); 239 if ( $image_alt != $post_data['_wp_attachment_image_alt'] ) { 240 $image_alt = wp_strip_all_tags( $post_data['_wp_attachment_image_alt'], true ); 241 wp_update_post_meta( $post_ID, '_wp_attachment_image_alt', $image_alt ); 239 if ( $image_alt != stripslashes( $post_data['_wp_attachment_image_alt'] ) ) { 240 $image_alt = wp_strip_all_tags( stripslashes( $post_data['_wp_attachment_image_alt'] ), true ); 241 // update_meta expects slashed 242 update_post_meta( $post_ID, '_wp_attachment_image_alt', addslashes( $image_alt ) ); 242 243 } 243 244 } … … 249 250 add_meta( $post_ID ); 250 251 251 wp_update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );252 update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); 252 253 253 254 wp_update_post( $post_data ); … … 430 431 $post_title = ''; 431 432 if ( !empty( $_REQUEST['post_title'] ) ) 432 $post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ));433 $post_title = esc_html( stripslashes( $_REQUEST['post_title'] )); 433 434 434 435 $post_content = ''; 435 436 if ( !empty( $_REQUEST['content'] ) ) 436 $post_content = esc_html( wp_unslash( $_REQUEST['content'] ));437 $post_content = esc_html( stripslashes( $_REQUEST['content'] )); 437 438 438 439 $post_excerpt = ''; 439 440 if ( !empty( $_REQUEST['excerpt'] ) ) 440 $post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ));441 $post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] )); 441 442 442 443 if ( $create_in_db ) { … … 487 488 global $wpdb; 488 489 489 $post_title = s anitize_post_field( 'post_title', $title, 0, 'db');490 $post_content = s anitize_post_field( 'post_content', $content, 0, 'db');491 $post_date = s anitize_post_field( 'post_date', $date, 0, 'db');490 $post_title = stripslashes( sanitize_post_field( 'post_title', $title, 0, 'db' ) ); 491 $post_content = stripslashes( sanitize_post_field( 'post_content', $content, 0, 'db' ) ); 492 $post_date = stripslashes( sanitize_post_field( 'post_date', $date, 0, 'db' ) ); 492 493 493 494 $query = "SELECT ID FROM $wpdb->posts WHERE 1=1"; … … 567 568 568 569 // Create the post. 569 $post_ID = wp_insert_post( wp_unslash( $_POST ));570 $post_ID = wp_insert_post( $_POST ); 570 571 if ( is_wp_error( $post_ID ) ) 571 572 return $post_ID; … … 576 577 add_meta( $post_ID ); 577 578 578 wp_add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );579 add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID ); 579 580 580 581 // Now that we have an ID we can fix any attachment anchor hrefs … … 620 621 $post_ID = (int) $post_ID; 621 622 622 $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';623 $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : '';624 $metavalue = isset($_POST['metavalue']) ? wp_unslash( trim( $_POST['metavalue'] ) ): '';623 $metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : ''; 624 $metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : ''; 625 $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : ''; 625 626 if ( is_string( $metavalue ) ) 626 627 $metavalue = trim( $metavalue ); … … 639 640 return false; 640 641 641 return wp_add_post_meta( $post_ID, $metakey, $metavalue ); 642 $metakey = esc_sql( $metakey ); 643 644 return add_post_meta( $post_ID, $metakey, $metavalue ); 642 645 } 643 646 … … 712 715 * 713 716 * @param unknown_type $meta_id 714 * @param unknown_type $meta_key 715 * @param unknown_type $meta_value 717 * @param unknown_type $meta_key Expect Slashed 718 * @param unknown_type $meta_value Expect Slashed 716 719 * @return unknown 717 720 */ 718 721 function update_meta( $meta_id, $meta_key, $meta_value ) { 722 $meta_key = stripslashes( $meta_key ); 723 $meta_value = stripslashes_deep( $meta_value ); 724 719 725 return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key ); 720 726 } … … 770 776 if ( $replace ) { 771 777 $post['post_content'] = $content; 778 // Escape data pulled from DB. 779 $post = add_magic_quotes($post); 772 780 773 781 return wp_update_post($post); … … 1180 1188 $lock = "$now:$user_id"; 1181 1189 1182 wp_update_post_meta( $post->ID, '_edit_lock', $lock );1190 update_post_meta( $post->ID, '_edit_lock', $lock ); 1183 1191 return array( $now, $user_id ); 1184 1192 } … … 1231 1239 // Only store one autosave. If there is already an autosave, overwrite it. 1232 1240 if ( $old_autosave = wp_get_post_autosave( $post_id ) ) { 1233 $new_autosave = _wp_post_revision_fields( wp_unslash( $_POST ), true );1241 $new_autosave = _wp_post_revision_fields( $_POST, true ); 1234 1242 $new_autosave['ID'] = $old_autosave->ID; 1235 1243 $new_autosave['post_author'] = get_current_user_id(); … … 1238 1246 1239 1247 // _wp_put_post_revision() expects unescaped. 1240 $_POST = wp_unslash( $_POST);1248 $_POST = stripslashes_deep($_POST); 1241 1249 1242 1250 // Otherwise create the new autosave as a special post revision
Note: See TracChangeset
for help on using the changeset viewer.