Plugin Directory

Changeset 3284372


Ignore:
Timestamp:
04/29/2025 08:01:46 PM (11 months ago)
Author:
derekspringer
Message:

SSRF Hardening / Yeast parse error fixes

Location:
beerxml-shortcode/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • beerxml-shortcode/trunk/beerxml-shortcode.php

    r1667900 r3284372  
    66Author: Derek Springer
    77Author URI: http://www.fivebladesbrewing.com/beerxml-plugin-wordpress/
    8 Version: 0.7.1
     8Version: 0.8
    99License: GPL2 or later
    1010Text Domain: beerxml-shortcode
     
    144144        }
    145145
    146         $recipe = esc_url_raw( $recipe );
    147         $recipe_filename = pathinfo( $recipe, PATHINFO_FILENAME );
     146        $recipe_loc = filter_var( esc_attr( $recipe ), FILTER_VALIDATE_URL );
     147        if ( ! $recipe_loc ) {
     148            return '<!-- Error parsing BeerXML document -->';
     149        }
     150
     151        $recipe_filename = pathinfo( $recipe_loc, PATHINFO_FILENAME );
    148152        $recipe_id = "beerxml_shortcode_recipe-{$post->ID}_{$recipe_filename}";
    149153
     
    164168
    165169        if ( ! $cache || false === ( $beer_xml = get_transient( $recipe_id ) ) ) {
    166             $beer_xml = new BeerXML( $recipe );
     170            $beer_xml = new BeerXML( $recipe_loc );
    167171        } else {
    168172            // result was in cache, just use that
     
    725729    static function build_yeast( $yeast, $metric = false ) {
    726730        if ( $metric ) {
    727             $yeast->min_temperature = round( $yeast->min_temperature, 2 );
    728             $yeast->max_temperature = round( $yeast->max_temperature, 2 );
     731            $yeast->min_temperature = round( floatval( $yeast->min_temperature ), 2 );
     732            $yeast->max_temperature = round( floatval( $yeast->max_temperature ), 2 );
    729733            $t_temp = __( 'C', 'beerxml-shortcode' );
    730734        } else {
    731             $yeast->min_temperature = round( ( $yeast->min_temperature * (9/5) ) + 32, 1 );
    732             $yeast->max_temperature = round( ( $yeast->max_temperature * (9/5) ) + 32, 1 );
     735            $yeast->min_temperature = round( ( floatval( $yeast->min_temperature ) * (9/5) ) + 32, 1 );
     736            $yeast->max_temperature = round( ( floatval( $yeast->max_temperature ) * (9/5) ) + 32, 1 );
    733737            $t_temp = __( 'F', 'beerxml-shortcode' );
    734738        }
  • beerxml-shortcode/trunk/includes/classes.php

    r895496 r3284372  
    66
    77    function __construct( $xml_loc ) {
    8         $response = wp_remote_get( $xml_loc );
     8        $response = wp_safe_remote_get( $xml_loc );
    99        if ( is_wp_error( $response ) ) {
    1010            $error_message = $response->get_error_message();
     
    2222        $xml = wp_remote_retrieve_body( $response );
    2323        $xrecipes = simplexml_load_string( $xml );
    24         if ( ! $xrecipes )
     24        if ( ! $xrecipes ) {
    2525            return;
     26        }
    2627
    2728        foreach ( $xrecipes->RECIPE as $recipe ) {
  • beerxml-shortcode/trunk/readme.txt

    r1763269 r3284372  
    44Tags: shortcode, beer, beerxml, homebrew, recipe
    55Requires at least: 3.4
    6 Tested up to: 4.9
    7 Stable tag: 0.7.1
     6Tested up to: 6.8
     7Stable tag: 0.8
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6060
    6161== Changelog ==
     62
     63= 0.8 =
     64
     65* Some potential SSRF fixes.
     66* Better error handling for yeasts that don't parse cleanly.
    6267
    6368= 0.7.1 =
Note: See TracChangeset for help on using the changeset viewer.