Skip to:
Content

BuddyPress.org

Ticket #3213: 3213-1.patch

File 3213-1.patch, 3.6 KB (added by boonebgorges, 14 years ago)
  • bp-xprofile/bp-xprofile-filters.php

    function xprofile_filter_kses( $content ) { 
    6666 *
    6767 * @param string $field_value
    6868 * @param int $field_id
     69 * @param bool $reserialize Whether to reserialize arrays before returning. Defaults to true
    6970 * @return string
    7071 */
    71 function xprofile_sanitize_data_value_before_save ( $field_value, $field_id ) {
     72function xprofile_sanitize_data_value_before_save ( $field_value, $field_id, $reserialize = true ) {
    7273
    7374        // Return if empty
    7475        if ( empty( $field_value ) )
    function xprofile_sanitize_data_value_before_save ( $field_value, $field_id ) { 
    9394                       
    9495                }
    9596
    96                 $filtered_field_value = serialize( $filtered_values );
     97                if ( $reserialize )
     98                        $filtered_field_value = serialize( $filtered_values );
     99                else
     100                        $filtered_field_value = $filtered_values;
    97101        }
    98102
    99103        return $filtered_field_value;
  • bp-xprofile/bp-xprofile-template.php

    function bp_the_profile_field_options( $args = '' ) { 
    432432
    433433                                        $selected = '';
    434434                                       
     435                                        // Run the allowed option name through the before_save
     436                                        // filter, so we'll be sure to get a match
     437                                        $allowed_options = xprofile_sanitize_data_value_before_save( $options[$k]->name, false, false );
     438                                       
    435439                                        // First, check to see whether the user-entered value
    436440                                        // matches
    437                                         if ( in_array( $options[$k]->name, (array) $option_values ) )
     441                                        if ( in_array( $allowed_options, (array) $option_values ) )
    438442                                                $selected = ' selected="selected"';
    439443
    440444                                        // Then, if the user has not provided a value, check for
    function bp_the_profile_field_options( $args = '' ) { 
    458462                                                        $option_value = $_POST['field_' . $field->id];
    459463                                        }
    460464                                       
     465                                        // Run the allowed option name through the before_save
     466                                        // filter, so we'll be sure to get a match
     467                                        $allowed_options = xprofile_sanitize_data_value_before_save( $options[$k]->name, false, false );
     468                                       
    461469                                        $selected = '';
    462                                         if ( $option_value == $options[$k]->name || !empty( $value ) && $value == $options[$k]->name || ( empty( $option_value ) && $options[$k]->is_default_option ) )
     470                                        if ( $option_value == $allowed_options || !empty( $value ) && $value == $allowed_options || ( empty( $option_value ) && $options[$k]->is_default_option ) )
    463471                                                $selected = ' checked="checked"';
    464472
    465473                                        $html .= apply_filters( 'bp_get_the_profile_field_options_radio', '<label><input' . $selected . ' type="radio" name="field_' . $field->id . '" id="option_' . $options[$k]->id . '" value="' . esc_attr( stripslashes( $options[$k]->name ) ) . '"> ' . esc_attr( stripslashes( $options[$k]->name ) ) . '</label>', $options[$k] );
    function bp_the_profile_field_options( $args = '' ) { 
    485493                                        // First, check to see whether the user's saved values
    486494                                        // match the option
    487495                                        for ( $j = 0; $j < count($option_values); $j++ ) {
    488                                                 if ( $option_values[$j] == $options[$k]->name || @in_array( $options[$k]->name, $value ) ) {
     496                                               
     497                                                // Run the allowed option name through the
     498                                                // before_save filter, so we'll be sure to get a
     499                                                // match
     500                                                $allowed_options = xprofile_sanitize_data_value_before_save( $options[$k]->name, false, false );
     501                                               
     502                                                if ( $option_values[$j] == $allowed_options || @in_array( $allowed_options, $value ) ) {
    489503                                                        $selected = ' checked="checked"';
    490504                                                        break;
    491505                                                }