Make WordPress Core

Changeset 18449


Ignore:
Timestamp:
07/21/2011 07:32:12 PM (13 years ago)
Author:
ryan
Message:

Check caps for both old and new meta keys when changing the key for a mid. Properly handle slashes when checking meta caps. Props xknown. see #17850

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r18445 r18449  
    870870        if ( !$meta = get_post_meta_by_id( $mid ) )
    871871            die('0'); // if meta doesn't exist
    872         if ( is_protected_meta( $meta->meta_key, 'post' ) || !current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) )
     872        if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
     873            ! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) ||
     874            ! current_user_can( 'edit_post_meta', $meta->post_id, $key ) )
    873875            die('-1');
    874876        if ( $meta->meta_value != stripslashes($value) || $meta->meta_key != stripslashes($key) ) {
  • trunk/wp-admin/includes/post.php

    r18445 r18449  
    668668    $metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : '';
    669669    $metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : '';
    670     $metavalue = isset($_POST['metavalue']) ? maybe_serialize( stripslashes_deep( $_POST['metavalue'] ) ) : '';
    671     if ( is_string($metavalue) )
     670    $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : '';
     671    if ( is_string( $metavalue ) )
    672672        $metavalue = trim( $metavalue );
    673673
    674     if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ((('#NONE#' != $metakeyselect) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput) ) ) {
     674    if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) {
    675675        // We have a key/value pair. If both the select and the
    676676        // input for the key have data, the input takes precedence:
    677677
    678         if ('#NONE#' != $metakeyselect)
     678        if ( '#NONE#' != $metakeyselect )
    679679            $metakey = $metakeyselect;
    680680
    681         if ( $metakeyinput)
     681        if ( $metakeyinput )
    682682            $metakey = $metakeyinput; // default
    683683
     
    685685            return false;
    686686
    687         return add_post_meta($post_ID, $metakey, $metavalue);
     687        $metakey = esc_sql( $metakey );
     688
     689        return add_post_meta( $post_ID, $metakey, $metavalue );
    688690    }
    689691
Note: See TracChangeset for help on using the changeset viewer.