Plugin Directory

Changeset 3287964


Ignore:
Timestamp:
05/05/2025 05:36:18 PM (9 months ago)
Author:
jazzs3quence
Message:

tagging version 2.2.4

Location:
progress-bar
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • progress-bar/tags/2.2.4/functions.php

    r2914360 r3287964  
    100100            $progress = str_replace( $currency, '', $progress );
    101101        }
     102       
    102103        $xofy = explode( '/', $progress );
    103         if ( ! $xofy[1] ) {
    104             $xofy[1] = 100;
    105         }
    106         $percentage = $xofy[0] / $xofy[1] * 100;
     104
     105        // Validate that both sides of the fraction are numeric.
     106        $x = ( isset( $xofy[0] ) ) && is_numeric( $xofy[0] ) ? $xofy[0] : 0;
     107        $y = ( isset( $xofy[1] ) ) && is_numeric( $xofy[1] ) ? $xofy[1] : 100;
     108
     109        $percentage = floatval( $x ) / floatval( $y ) * 100;
    107110        $width = $percentage . '%';
    108111        if ( $has_currency_symbol === false ) {
    109             $progress = number_format_i18n( $xofy[0] ) . ' / ' . number_format_i18n( $xofy[1] );
     112            $progress = number_format_i18n( $x ) . ' / ' . number_format_i18n( $y );
    110113        } else {
    111114            // If there's a currency symbol in the progress, display it manually.
    112             $progress = $currency . number_format_i18n( $xofy[0] ) . ' / ' . $currency . number_format_i18n( $xofy[1] );
     115            $progress = $currency . number_format_i18n( $x ) . ' / ' . $currency . number_format_i18n( $y );
    113116        }
    114117    }
     
    133136 */
    134137function wppb_get_progress_bar( $location = false, $text = false, $progress = '', $option = false, $width = '', $fullwidth = false, $color = false, $gradient = false, $gradient_end = false ) {
    135     // Sanitize user input.
    136     $location = sanitize_html_class( esc_attr( $location ) );
    137     $text = sanitize_text_field( esc_attr( $text ) );
    138     $width = floatval( $width );
    139     $fullwidth = sanitize_html_class( esc_attr( $fullwidth ) );
    140     $color = esc_attr( wppb_sanitize_color( $color ) );
    141     $gradient = esc_attr( wppb_sanitize_color( $gradient ) );
    142     $gradient_end = esc_attr( wppb_sanitize_color( $gradient_end ) );
    143     $option = esc_attr( wppb_sanitize_option( $option ) );
     138    /*
     139     * Sanitize user input.
     140     * This would be better handled as we're outputting the variables. We're pre-escaping here for convenience, but need to remember to not escape again later inside the strings.
     141     */
     142    $location = isset( $location ) ? esc_attr( sanitize_html_class( $location ) ) : $location;
     143    $text_exists = ! is_bool( $text ) && trim( $text ) !== '';
     144    $text = $text_exists ? esc_html( sanitize_text_field( $text ) ) : $text;
     145    $width = isset( $width ) ? floatval( $width ) : $width;
     146    $fullwidth = isset( $fullwidth ) ? esc_attr( $fullwidth ) : $fullwidth;
     147    $color = is_string( $color ) ? esc_attr( wppb_sanitize_color( $color ) ) : '';
     148    $gradient = isset( $gradient ) ? esc_attr( floatval( $gradient ) ) : $gradient;
     149    $gradient_end = is_string( $gradient_end ) ? esc_attr( wppb_sanitize_color( $gradient_end ) ) : '';
     150    $option = isset( $option ) ? esc_attr( wppb_sanitize_option( $option ) ) : $option;
     151    $progress = isset( $progress ) ? esc_html( sanitize_text_field( $progress ) ) : $progress;
     152
     153    // Calculate $gradient_end if missing.
     154    if ( $gradient && $color && ! $gradient_end ) {
     155        $gradient_end = wppb_brightness( $color, floatval( $gradient ) );
     156    }
    144157
    145158    // Throw an exception if $progress or $width are empty.
     
    173186        $wppb_output .= $progress;
    174187        $wppb_output .= '</div>';
    175     } elseif ( ! $location && $text ) { // If the location is not set, but there is custom text.
     188    } elseif ( ! $location && $text_exists ) { // If the location is not set, but there is custom text.
    176189        $wppb_output .= "<div class=\"inside\">$text</div>";
    177190    }
     
    190203        $wppb_output .= " style=\"width: $width%; background: {$color};";
    191204        if ( $gradient_end ) {
    192             $wppb_output .= "background: -moz-linear-gradient(top, {$color} 0%, $gradient_end 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,{$color}), color-stop(100%,$gradient_end)); background: -webkit-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -o-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -ms-linear-gradient(top, {$gradient} 0%,$gradient_end 100%); background: linear-gradient(top, {$color} 0%,$gradient_end 100%); \"";
    193         }
     205            $wppb_output .= "background: -moz-linear-gradient(top, {$color} 0%, $gradient_end 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,{$color}), color-stop(100%,$gradient_end)); background: -webkit-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -o-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -ms-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: linear-gradient(top, {$color} 0%,$gradient_end 100%); \"";
     206        }
     207        $wppb_output .= '"';
    194208    } else {
    195         $wppb_output .= " style=\"width: $width%;";
    196     }
    197     if ( $gradient && $color ) {
    198         $wppb_output .= "background: -moz-linear-gradient(top, {$color} 0%, $gradient_end 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,{$color}), color-stop(100%,$gradient_end)); background: -webkit-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -o-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -ms-linear-gradient(top, {$gradient} 0%,$gradient_end 100%); background: linear-gradient(top, {$color} 0%,$gradient_end 100%); \"";
    199     } else {
    200         $wppb_output .= '"';
     209        $wppb_output .= " style=\"width: $width%;\"";
    201210    }
    202211    $wppb_output .= '><span></span></span>';
     
    216225 */
    217226function wppb_sanitize_color( $color = '' ) {
    218     if ( '' === $color ) {
    219         return $color;
     227    if ( ! is_string( $color ) ) {
     228        return '';
    220229    }
    221230
     
    229238
    230239    // Check if $color contains a hexadecimal or rgb value. If neither, return an empty string..
    231     if ( false === strpos( $color, '#' ) && false === strpos( $color, 'rgb(' ) && false === strpos( $color, 'rgba(' ) ) {
     240    if ( false === strpos( $color, '#' ) &&
     241        false === strpos( $color, 'rgb(' ) &&
     242        false === strpos( $color, 'rgba(' )
     243    ) {
    232244        // If the string is not a valid hexadecimal value, return an empty string.
    233         if ( ! ctype_xdigit( $color ) && ( strlen( $color ) !== 3 || strlen( $color ) !== 6 ) ) {
     245        if ( ! ctype_xdigit( $color ) || ( strlen( $color ) !== 3 && strlen( $color ) !== 6 ) ) {
    234246            return '';
    235247        }
     
    239251    if ( false !== strpos( $color, '#' ) ) {
    240252        $color = sanitize_hex_color( $color );
    241     }
    242 
    243     // If $color contains an rgb/rgba value, sanitize it.
    244     if ( false !== strpos( $color, 'rgb(' ) || false !== strpos( $color, 'rgba(' ) ) {
    245         $color = sanitize_text_field( $color );
     253
     254        // If sanitize_hex_color() failed, return early.
     255        if ( ! is_string( $color ) || $color === '' ) {
     256            return '';
     257        }
    246258    }
    247259
     
    340352        'honeydew',
    341353        'hotpink',
    342         'indianred ',
    343         'indigo ',
     354        'indianred',
     355        'indigo',
    344356        'ivory',
    345357        'khaki',
  • progress-bar/tags/2.2.4/phpcs.ruleset.xml

    r2914360 r3287964  
    44    <exclude-pattern>vendor/</exclude-pattern>
    55    <exclude-pattern>tests/</exclude-pattern>
     6    <ini name="error_reporting" value="E_ALL &#38; ~E_DEPRECATED" />
    67    <rule ref="Pantheon-WP">
    78        <exclude name="WordPress.Files.FileName.InvalidClassFileName" />
  • progress-bar/tags/2.2.4/readme.txt

    r2914360 r3287964  
    44Tags: progress bar, css3, progress, shortcode
    55Requires at least: 2.8
    6 Tested up to: 6.2.1
    7 Stable tag: 2.2.3
     6Tested up to: 6.7.2
     7Stable tag: 2.2.4
    88
    99A simple progress bar shortcode that can be styled with CSS
     
    169169
    170170Makes the progress bar take up 100% of the container. (Good for responsive layouts.) *Not* recommended for progress bars that exceed their goal.
    171 *Note:* `fullwidth` will actually take any value. If `fullwidth` is present at all, it will display a progress bar that is 100% wide. For example `fullwidth=foo` would output the same as `fullwidth=true`.
     171*Note:* As of 2.2.4, `fullwidth` will _only take truthy_ values. Previously, it would accept any value, e.g. `fullwidth=foo` would output the same as `fullwidth=true`. This is no longer the case.
    172172
    173173Supported value: true
     
    227227
    228228== Upgrade Notice ==
     229** 2.2.4 **
     230
     231* Previously, the `fullwidth` parameter would accept any value. This has been updated to use the PHP `FILTER_VALIDATE_BOOLEAN` constant so that only "truthy" values (1, true, "true", "yes", etc.) are supported.
     232
    229233** 2.2.0 **
    230234
     
    233237
    234238== Changelog ==
     239
     240** 2.2.4 **
     241* Fixed XSS vulnerability reported by muhammad yudha for [Patchstack](https://patchstack.com)
     242* Cleaned up and refactored some possibly buggy code and sanitization/escaping issues.
    235243
    236244** 2.2.3 **
  • progress-bar/tags/2.2.4/wp-progress-bar.php

    r2914360 r3287964  
    44 * Plugin URI: https://github.com/jazzsequence/progress-bar
    55 * Description: A simple progress bar shortcode that can be styled with CSS.
    6  * Version: 2.2.3
     6 * Version: 2.2.4
    77 * Author: Chris Reynolds
    88 * Author URI: https://progressbar.jazzsequence.com/
     
    3535 * @return string
    3636 */
    37 function wppb_version() : string {
    38     return '2.2.3';
     37function wppb_version(): string {
     38    return '2.2.4';
    3939}
    4040
     
    5353}
    5454add_action( 'init', 'wppb_init' );
     55
     56/**
     57 * Register the widget.
     58 *
     59 * @author Chris Reynolds
     60 * @since 2.0.1
     61 * @uses WP_Widget
     62 */
     63function wppb_register_widget() {
     64    register_widget( 'WPPB_Widget' );
     65}
     66add_action( 'widgets_init', 'wppb_register_widget' );
    5567
    5668/**
     
    104116
    105117    // Get the values of the shortcode attributes.
    106     $progress = isset( $atts['progress'] ) ? $atts['progress'] : '';
    107     $option = isset( $atts['option'] ) ? $atts['option'] : '';
    108     $percent = isset( $atts['percent'] ) ? $atts['percent'] : '';
    109     $location = isset( $atts['location'] ) ? $atts['location'] : '';
    110     $fullwidth = isset( $atts['fullwidth'] ) ? $atts['fullwidth'] : '';
    111     $color = isset( $atts['color'] ) ? $atts['color'] : '';
    112     $gradient = isset( $atts['gradient'] ) ? $atts['gradient'] : '';
    113     $endcolor = isset( $atts['endcolor'] ) ? $atts['endcolor'] : '';
    114     $text = isset( $atts['text'] ) ? $atts['text'] : '';
     118    $progress = isset( $atts['progress'] ) ? sanitize_text_field( $atts['progress'] ) : '';
     119    $option = isset( $atts['option'] ) ? wppb_sanitize_option( $atts['option'] ) : '';
     120    $percent = isset( $atts['percent'] ) ? sanitize_text_field( $atts['percent'] ) : '';
     121    $location = isset( $atts['location'] ) ? $atts['location'] : ''; // Sanitization handled in wppb_get_progress_bar.
     122    $fullwidth = isset( $atts['fullwidth'] ) ? filter_var( $atts['fullwidth'], FILTER_VALIDATE_BOOLEAN ) : '';
     123    $color = isset( $atts['color'] ) ? wppb_sanitize_color( $atts['color'] ) : '';
     124    $gradient = isset( $atts['gradient'] ) ? sanitize_text_field( $atts['gradient'] ) : '';
     125    $endcolor = isset( $atts['endcolor'] ) ? wppb_sanitize_color( $atts['endcolor'] ) : '';
     126    $text = isset( $atts['text'] ) ? sanitize_text_field( $atts['text'] ) : '';
    115127
    116128    // Check the progress for a slash, indicating a fraction instead of a percent.
     
    130142    }
    131143
    132     // Sanitize any text content.
    133     if ( $text !== '' ) {
    134         $text = wp_strip_all_tags( $text );
    135     }
    136 
    137144    // Figure out gradient stuff.
    138145    $gradient_end = null;
     
    144151    }
    145152
    146     if ( $fullwidth !== '' ) {
    147         $fullwidth = true;
    148     }
    149 
    150153    $progress = $wppb_check_results[0];
    151154
  • progress-bar/tags/2.2.4/wppb-widget.php

    r2909774 r3287964  
    66 * @package WP_Progress_Bar
    77 */
    8 
    9 /**
    10  * Register the widget.
    11  *
    12  * @author Chris Reynolds
    13  * @since 2.0.1
    14  * @uses WP_Widget
    15  */
    16 function wppb_register_widget() {
    17     register_widget( 'WPPB_Widget' );
    18 }
    19 add_action( 'widgets_init', 'wppb_register_widget' );
    208
    219/**
     
    9886        }
    9987
    100         $option = null;
    101         if ( $color ) {
    102             $option .= $color;
    103         }
    104         if ( $candystripe ) {
    105             $option .= ' ' . $candystripe;
    106         }
     88        $option = wppb_sanitize_option( trim( "$color $candystripe" ) );
    10789
    10890        echo wp_kses_post( wppb_get_progress_bar( $location, $text, $percent, $option, $width, 'true' ) );
    10991        echo wp_kses_post( wpautop( $description ) );
    11092        echo wp_kses_post( $args['after_widget'] );
    111 
    11293    }
    11394
     
    242223        <p>
    243224            <label for="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"><strong><?php esc_html_e( 'Text', 'wp-progress-bar' ); ?></strong></label>
    244             <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" type="text" value="<?php wp_kses_post( $text ); ?>" /><br />
     225            <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" type="text" value="<?php echo esc_attr( $text ); ?>" /><br />
    245226            <span class="description"><?php esc_html_e( 'Custom text to display (instead of the progress value). (optional).', 'wp-progress-bar' ); ?></span>
    246227        </p>
  • progress-bar/trunk/functions.php

    r2914360 r3287964  
    100100            $progress = str_replace( $currency, '', $progress );
    101101        }
     102       
    102103        $xofy = explode( '/', $progress );
    103         if ( ! $xofy[1] ) {
    104             $xofy[1] = 100;
    105         }
    106         $percentage = $xofy[0] / $xofy[1] * 100;
     104
     105        // Validate that both sides of the fraction are numeric.
     106        $x = ( isset( $xofy[0] ) ) && is_numeric( $xofy[0] ) ? $xofy[0] : 0;
     107        $y = ( isset( $xofy[1] ) ) && is_numeric( $xofy[1] ) ? $xofy[1] : 100;
     108
     109        $percentage = floatval( $x ) / floatval( $y ) * 100;
    107110        $width = $percentage . '%';
    108111        if ( $has_currency_symbol === false ) {
    109             $progress = number_format_i18n( $xofy[0] ) . ' / ' . number_format_i18n( $xofy[1] );
     112            $progress = number_format_i18n( $x ) . ' / ' . number_format_i18n( $y );
    110113        } else {
    111114            // If there's a currency symbol in the progress, display it manually.
    112             $progress = $currency . number_format_i18n( $xofy[0] ) . ' / ' . $currency . number_format_i18n( $xofy[1] );
     115            $progress = $currency . number_format_i18n( $x ) . ' / ' . $currency . number_format_i18n( $y );
    113116        }
    114117    }
     
    133136 */
    134137function wppb_get_progress_bar( $location = false, $text = false, $progress = '', $option = false, $width = '', $fullwidth = false, $color = false, $gradient = false, $gradient_end = false ) {
    135     // Sanitize user input.
    136     $location = sanitize_html_class( esc_attr( $location ) );
    137     $text = sanitize_text_field( esc_attr( $text ) );
    138     $width = floatval( $width );
    139     $fullwidth = sanitize_html_class( esc_attr( $fullwidth ) );
    140     $color = esc_attr( wppb_sanitize_color( $color ) );
    141     $gradient = esc_attr( wppb_sanitize_color( $gradient ) );
    142     $gradient_end = esc_attr( wppb_sanitize_color( $gradient_end ) );
    143     $option = esc_attr( wppb_sanitize_option( $option ) );
     138    /*
     139     * Sanitize user input.
     140     * This would be better handled as we're outputting the variables. We're pre-escaping here for convenience, but need to remember to not escape again later inside the strings.
     141     */
     142    $location = isset( $location ) ? esc_attr( sanitize_html_class( $location ) ) : $location;
     143    $text_exists = ! is_bool( $text ) && trim( $text ) !== '';
     144    $text = $text_exists ? esc_html( sanitize_text_field( $text ) ) : $text;
     145    $width = isset( $width ) ? floatval( $width ) : $width;
     146    $fullwidth = isset( $fullwidth ) ? esc_attr( $fullwidth ) : $fullwidth;
     147    $color = is_string( $color ) ? esc_attr( wppb_sanitize_color( $color ) ) : '';
     148    $gradient = isset( $gradient ) ? esc_attr( floatval( $gradient ) ) : $gradient;
     149    $gradient_end = is_string( $gradient_end ) ? esc_attr( wppb_sanitize_color( $gradient_end ) ) : '';
     150    $option = isset( $option ) ? esc_attr( wppb_sanitize_option( $option ) ) : $option;
     151    $progress = isset( $progress ) ? esc_html( sanitize_text_field( $progress ) ) : $progress;
     152
     153    // Calculate $gradient_end if missing.
     154    if ( $gradient && $color && ! $gradient_end ) {
     155        $gradient_end = wppb_brightness( $color, floatval( $gradient ) );
     156    }
    144157
    145158    // Throw an exception if $progress or $width are empty.
     
    173186        $wppb_output .= $progress;
    174187        $wppb_output .= '</div>';
    175     } elseif ( ! $location && $text ) { // If the location is not set, but there is custom text.
     188    } elseif ( ! $location && $text_exists ) { // If the location is not set, but there is custom text.
    176189        $wppb_output .= "<div class=\"inside\">$text</div>";
    177190    }
     
    190203        $wppb_output .= " style=\"width: $width%; background: {$color};";
    191204        if ( $gradient_end ) {
    192             $wppb_output .= "background: -moz-linear-gradient(top, {$color} 0%, $gradient_end 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,{$color}), color-stop(100%,$gradient_end)); background: -webkit-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -o-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -ms-linear-gradient(top, {$gradient} 0%,$gradient_end 100%); background: linear-gradient(top, {$color} 0%,$gradient_end 100%); \"";
    193         }
     205            $wppb_output .= "background: -moz-linear-gradient(top, {$color} 0%, $gradient_end 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,{$color}), color-stop(100%,$gradient_end)); background: -webkit-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -o-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -ms-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: linear-gradient(top, {$color} 0%,$gradient_end 100%); \"";
     206        }
     207        $wppb_output .= '"';
    194208    } else {
    195         $wppb_output .= " style=\"width: $width%;";
    196     }
    197     if ( $gradient && $color ) {
    198         $wppb_output .= "background: -moz-linear-gradient(top, {$color} 0%, $gradient_end 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,{$color}), color-stop(100%,$gradient_end)); background: -webkit-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -o-linear-gradient(top, {$color} 0%,$gradient_end 100%); background: -ms-linear-gradient(top, {$gradient} 0%,$gradient_end 100%); background: linear-gradient(top, {$color} 0%,$gradient_end 100%); \"";
    199     } else {
    200         $wppb_output .= '"';
     209        $wppb_output .= " style=\"width: $width%;\"";
    201210    }
    202211    $wppb_output .= '><span></span></span>';
     
    216225 */
    217226function wppb_sanitize_color( $color = '' ) {
    218     if ( '' === $color ) {
    219         return $color;
     227    if ( ! is_string( $color ) ) {
     228        return '';
    220229    }
    221230
     
    229238
    230239    // Check if $color contains a hexadecimal or rgb value. If neither, return an empty string..
    231     if ( false === strpos( $color, '#' ) && false === strpos( $color, 'rgb(' ) && false === strpos( $color, 'rgba(' ) ) {
     240    if ( false === strpos( $color, '#' ) &&
     241        false === strpos( $color, 'rgb(' ) &&
     242        false === strpos( $color, 'rgba(' )
     243    ) {
    232244        // If the string is not a valid hexadecimal value, return an empty string.
    233         if ( ! ctype_xdigit( $color ) && ( strlen( $color ) !== 3 || strlen( $color ) !== 6 ) ) {
     245        if ( ! ctype_xdigit( $color ) || ( strlen( $color ) !== 3 && strlen( $color ) !== 6 ) ) {
    234246            return '';
    235247        }
     
    239251    if ( false !== strpos( $color, '#' ) ) {
    240252        $color = sanitize_hex_color( $color );
    241     }
    242 
    243     // If $color contains an rgb/rgba value, sanitize it.
    244     if ( false !== strpos( $color, 'rgb(' ) || false !== strpos( $color, 'rgba(' ) ) {
    245         $color = sanitize_text_field( $color );
     253
     254        // If sanitize_hex_color() failed, return early.
     255        if ( ! is_string( $color ) || $color === '' ) {
     256            return '';
     257        }
    246258    }
    247259
     
    340352        'honeydew',
    341353        'hotpink',
    342         'indianred ',
    343         'indigo ',
     354        'indianred',
     355        'indigo',
    344356        'ivory',
    345357        'khaki',
  • progress-bar/trunk/phpcs.ruleset.xml

    r2914360 r3287964  
    44    <exclude-pattern>vendor/</exclude-pattern>
    55    <exclude-pattern>tests/</exclude-pattern>
     6    <ini name="error_reporting" value="E_ALL &#38; ~E_DEPRECATED" />
    67    <rule ref="Pantheon-WP">
    78        <exclude name="WordPress.Files.FileName.InvalidClassFileName" />
  • progress-bar/trunk/readme.txt

    r2914360 r3287964  
    44Tags: progress bar, css3, progress, shortcode
    55Requires at least: 2.8
    6 Tested up to: 6.2.1
    7 Stable tag: 2.2.3
     6Tested up to: 6.7.2
     7Stable tag: 2.2.4
    88
    99A simple progress bar shortcode that can be styled with CSS
     
    169169
    170170Makes the progress bar take up 100% of the container. (Good for responsive layouts.) *Not* recommended for progress bars that exceed their goal.
    171 *Note:* `fullwidth` will actually take any value. If `fullwidth` is present at all, it will display a progress bar that is 100% wide. For example `fullwidth=foo` would output the same as `fullwidth=true`.
     171*Note:* As of 2.2.4, `fullwidth` will _only take truthy_ values. Previously, it would accept any value, e.g. `fullwidth=foo` would output the same as `fullwidth=true`. This is no longer the case.
    172172
    173173Supported value: true
     
    227227
    228228== Upgrade Notice ==
     229** 2.2.4 **
     230
     231* Previously, the `fullwidth` parameter would accept any value. This has been updated to use the PHP `FILTER_VALIDATE_BOOLEAN` constant so that only "truthy" values (1, true, "true", "yes", etc.) are supported.
     232
    229233** 2.2.0 **
    230234
     
    233237
    234238== Changelog ==
     239
     240** 2.2.4 **
     241* Fixed XSS vulnerability reported by muhammad yudha for [Patchstack](https://patchstack.com)
     242* Cleaned up and refactored some possibly buggy code and sanitization/escaping issues.
    235243
    236244** 2.2.3 **
  • progress-bar/trunk/wp-progress-bar.php

    r2914360 r3287964  
    44 * Plugin URI: https://github.com/jazzsequence/progress-bar
    55 * Description: A simple progress bar shortcode that can be styled with CSS.
    6  * Version: 2.2.3
     6 * Version: 2.2.4
    77 * Author: Chris Reynolds
    88 * Author URI: https://progressbar.jazzsequence.com/
     
    3535 * @return string
    3636 */
    37 function wppb_version() : string {
    38     return '2.2.3';
     37function wppb_version(): string {
     38    return '2.2.4';
    3939}
    4040
     
    5353}
    5454add_action( 'init', 'wppb_init' );
     55
     56/**
     57 * Register the widget.
     58 *
     59 * @author Chris Reynolds
     60 * @since 2.0.1
     61 * @uses WP_Widget
     62 */
     63function wppb_register_widget() {
     64    register_widget( 'WPPB_Widget' );
     65}
     66add_action( 'widgets_init', 'wppb_register_widget' );
    5567
    5668/**
     
    104116
    105117    // Get the values of the shortcode attributes.
    106     $progress = isset( $atts['progress'] ) ? $atts['progress'] : '';
    107     $option = isset( $atts['option'] ) ? $atts['option'] : '';
    108     $percent = isset( $atts['percent'] ) ? $atts['percent'] : '';
    109     $location = isset( $atts['location'] ) ? $atts['location'] : '';
    110     $fullwidth = isset( $atts['fullwidth'] ) ? $atts['fullwidth'] : '';
    111     $color = isset( $atts['color'] ) ? $atts['color'] : '';
    112     $gradient = isset( $atts['gradient'] ) ? $atts['gradient'] : '';
    113     $endcolor = isset( $atts['endcolor'] ) ? $atts['endcolor'] : '';
    114     $text = isset( $atts['text'] ) ? $atts['text'] : '';
     118    $progress = isset( $atts['progress'] ) ? sanitize_text_field( $atts['progress'] ) : '';
     119    $option = isset( $atts['option'] ) ? wppb_sanitize_option( $atts['option'] ) : '';
     120    $percent = isset( $atts['percent'] ) ? sanitize_text_field( $atts['percent'] ) : '';
     121    $location = isset( $atts['location'] ) ? $atts['location'] : ''; // Sanitization handled in wppb_get_progress_bar.
     122    $fullwidth = isset( $atts['fullwidth'] ) ? filter_var( $atts['fullwidth'], FILTER_VALIDATE_BOOLEAN ) : '';
     123    $color = isset( $atts['color'] ) ? wppb_sanitize_color( $atts['color'] ) : '';
     124    $gradient = isset( $atts['gradient'] ) ? sanitize_text_field( $atts['gradient'] ) : '';
     125    $endcolor = isset( $atts['endcolor'] ) ? wppb_sanitize_color( $atts['endcolor'] ) : '';
     126    $text = isset( $atts['text'] ) ? sanitize_text_field( $atts['text'] ) : '';
    115127
    116128    // Check the progress for a slash, indicating a fraction instead of a percent.
     
    130142    }
    131143
    132     // Sanitize any text content.
    133     if ( $text !== '' ) {
    134         $text = wp_strip_all_tags( $text );
    135     }
    136 
    137144    // Figure out gradient stuff.
    138145    $gradient_end = null;
     
    144151    }
    145152
    146     if ( $fullwidth !== '' ) {
    147         $fullwidth = true;
    148     }
    149 
    150153    $progress = $wppb_check_results[0];
    151154
  • progress-bar/trunk/wppb-widget.php

    r2909774 r3287964  
    66 * @package WP_Progress_Bar
    77 */
    8 
    9 /**
    10  * Register the widget.
    11  *
    12  * @author Chris Reynolds
    13  * @since 2.0.1
    14  * @uses WP_Widget
    15  */
    16 function wppb_register_widget() {
    17     register_widget( 'WPPB_Widget' );
    18 }
    19 add_action( 'widgets_init', 'wppb_register_widget' );
    208
    219/**
     
    9886        }
    9987
    100         $option = null;
    101         if ( $color ) {
    102             $option .= $color;
    103         }
    104         if ( $candystripe ) {
    105             $option .= ' ' . $candystripe;
    106         }
     88        $option = wppb_sanitize_option( trim( "$color $candystripe" ) );
    10789
    10890        echo wp_kses_post( wppb_get_progress_bar( $location, $text, $percent, $option, $width, 'true' ) );
    10991        echo wp_kses_post( wpautop( $description ) );
    11092        echo wp_kses_post( $args['after_widget'] );
    111 
    11293    }
    11394
     
    242223        <p>
    243224            <label for="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>"><strong><?php esc_html_e( 'Text', 'wp-progress-bar' ); ?></strong></label>
    244             <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" type="text" value="<?php wp_kses_post( $text ); ?>" /><br />
     225            <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" type="text" value="<?php echo esc_attr( $text ); ?>" /><br />
    245226            <span class="description"><?php esc_html_e( 'Custom text to display (instead of the progress value). (optional).', 'wp-progress-bar' ); ?></span>
    246227        </p>
Note: See TracChangeset for help on using the changeset viewer.