Make WordPress Core

Changeset 18356


Ignore:
Timestamp:
06/27/2011 09:36:48 PM (14 years ago)
Author:
ryan
Message:

Hardening. Santizers for WPLANG and new_admin_email. Prevent stomping ID and filter. Validate locale filename. Props westi. For 3.1.

Location:
branches/3.1
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1

  • branches/3.1/wp-admin/custom-header.php

    r18023 r18356  
    597597        'post_mime_type' => $type,
    598598        'guid' => $url,
    599         'context' => 'custom-header');
     599        'context' => 'custom-header'
     600        );
    600601
    601602        // Save the data
  • branches/3.1/wp-admin/includes/media.php

    r18018 r18356  
    229229    ), $post_data );
    230230
     231    // This should never be set as it would then overwrite an existing attachment.
     232    if ( isset( $attachment['ID'] ) )
     233        unset( $attachment['ID'] );
     234
    231235    // Save the data
    232236    $id = wp_insert_attachment($attachment, $file, $post_id);
     
    281285        'post_content' => $content,
    282286    ), $post_data );
     287
     288    // This should never be set as it would then overwrite an existing attachment.
     289    if ( isset( $attachment['ID'] ) )
     290        unset( $attachment['ID'] );
    283291
    284292    // Save the attachment metadata
  • branches/3.1/wp-admin/includes/post.php

    r18054 r18356  
    135135    if ( empty($post_data) )
    136136        $post_data = &$_POST;
     137
     138    // Clear out any data in internal vars.
     139    if ( isset( $post_data['filter'] ) )
     140        unset( $post_data['filter'] );
    137141
    138142    $post_ID = (int) $post_data['post_ID'];
     
    552556            return edit_post();
    553557        }
     558    }
     559
     560    // Edit don't write if we have a post id.
     561    if ( isset( $_POST['ID'] ) ) {
     562        $_POST['post_ID'] = $_POST['ID'];
     563        unset ( $_POST['ID'] );
     564    }
     565    if ( isset( $_POST['post_ID'] ) ) {
     566        return edit_post();
    554567    }
    555568
  • branches/3.1/wp-admin/options-general.php

    r16736 r18356  
    128128if ( $new_admin_email && $new_admin_email != get_option('admin_email') ) : ?>
    129129<div class="updated inline">
    130 <p><?php printf( __('There is a pending change of the admin e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_admin_email, esc_url( admin_url( 'options.php?dismiss=new_admin_email' ) ) ); ?></p>
     130<p><?php printf( __('There is a pending change of the admin e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), esc_html( $new_admin_email ), esc_url( admin_url( 'options.php?dismiss=new_admin_email' ) ) ); ?></p>
    131131</div>
    132132<?php endif; ?>
  • branches/3.1/wp-includes/formatting.php

    r18353 r18356  
    24412441            }
    24422442            break;
    2443 
     2443        case 'new_admin_email':
     2444            $value = sanitize_email($value);
     2445            if ( !is_email($value) ) {
     2446                $value = get_option( $option ); // Resets option to stored value in the case of failed sanitization
     2447                if ( function_exists('add_settings_error') )
     2448                    add_settings_error('new_admin_email', 'invalid_admin_email', __('The email address entered did not appear to be a valid email address. Please enter a valid email address.'));
     2449            }
     2450            break;
    24442451        case 'thumbnail_size_w':
    24452452        case 'thumbnail_size_h':
     
    25352542            }
    25362543            break;
     2544        case 'WPLANG':
     2545            $allowed = get_available_languages();
     2546            if ( ! in_array( $value, $allowed ) && ! empty( $value ) )
     2547                $value = get_option( $option );
     2548            break;
    25372549
    25382550        default :
  • branches/3.1/wp-settings.php

    r16558 r18356  
    259259$locale = get_locale();
    260260$locale_file = WP_LANG_DIR . "/$locale.php";
    261 if ( is_readable( $locale_file ) )
     261if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) )
    262262    require( $locale_file );
    263263unset($locale_file);
Note: See TracChangeset for help on using the changeset viewer.