Making WordPress.org

Changeset 5901


Ignore:
Timestamp:
09/08/2017 07:02:20 PM (8 years ago)
Author:
iandunn
Message:

WordCamp Base: Switch layout signature from PHP serialization to JSON.

Unserializing user input is dangerous because it can lead to PHP object injection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/themes/wordcamp-base/lib/options/class-wcb-grid-option.php

    r5897 r5901  
    2626
    2727    function validate_layout( $input ) {
    28         $input = unserialize( $input );
     28        $input = json_decode( $input );
    2929        if ( ! is_array( $input ) )
    3030            return null;
     
    107107        <div id="<?php echo esc_attr("grid-row-$this->key"); ?>" class="grid-row-layout clearfix <?php echo $this->get_option('visible') ? 'visible' : ''; ?>">
    108108            <div class="description row-name"><?php echo esc_html( $this->label ); ?></div>
    109             <input class="signature" type="hidden" <?php $this->name('layout'); ?> value="<?php echo esc_attr( serialize( $layout ) ); ?>"/>
     109            <input class="signature" type="hidden" <?php $this->name('layout'); ?> value="<?php echo esc_attr( wp_json_encode( $layout ) ); ?>"/>
    110110            <?php $this->render_row( $layout ); ?>
    111111            <div class="edit"><a href="#"><?php echo esc_html_e( 'Edit' , 'wordcamporg'); ?></a></div>
     
    134134                        $active = $this->verbose_row( $row ) == $current_layout; ?>
    135135                        <a href="#" class="grid-row-selector <?php echo $active ? 'active' : ''; ?>">
    136                             <input class="grid-row-signature" type="hidden" value="<?php echo esc_attr( serialize( $row ) ); ?>"/>
     136                            <input class="grid-row-signature" type="hidden" value="<?php echo esc_attr( wp_json_encode( $row ) ); ?>"/>
    137137                            <?php $this->render_row( $row ); ?>
    138138                        </a>
Note: See TracChangeset for help on using the changeset viewer.