From 9f94b7d51d122e24b45a36981feef23d47a787ea Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Thu, 19 Jan 2017 15:48:15 -0800 Subject: [PATCH] 12518 Sanitizing and brackets --- .../single-product/product-attributes.php | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/templates/single-product/product-attributes.php b/templates/single-product/product-attributes.php index 8b5c412278e..1b545e1ae86 100644 --- a/templates/single-product/product-attributes.php +++ b/templates/single-product/product-attributes.php @@ -43,22 +43,32 @@ if ( ! defined( 'ABSPATH' ) ) { is_taxonomy() ) : + if ( $attribute->is_taxonomy() ) { $attribute_taxonomy = $attribute->get_taxonomy_object(); $attribute_values = wc_get_product_terms( $product->get_id(), $attribute->get_name(), array( 'fields' => 'all' ) ); - foreach ( $attribute_values as $attribute_value ) : - if ( $attribute_taxonomy->attribute_public ) : - $values[] = ''; - else: - $values[] = $attribute_value->name; - endif; - endforeach; + foreach ( $attribute_values as $attribute_value ) { + + $value_name = esc_html( $attribute_value->name ); + + if ( $attribute_taxonomy->attribute_public ) { + $values[] = ''; + } else { + $values[] = $value_name; + } + + } + + } else { - else : $values = $attribute->get_options(); - endif; + + foreach ( $values as &$value ) { + $value = esc_html( $value ); + } + + } echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values ); ?>