From 7f8add52a76bd68536d8c4c1c94eea8482b293c5 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 24 May 2017 18:01:19 +0100 Subject: [PATCH] Fix saving of text attributes with special chars Fixes #15238 --- includes/class-wc-product-attribute.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-product-attribute.php b/includes/class-wc-product-attribute.php index ab730ad22a8..cad8804b55a 100644 --- a/includes/class-wc-product-attribute.php +++ b/includes/class-wc-product-attribute.php @@ -73,7 +73,8 @@ class WC_Product_Attribute implements ArrayAccess { if ( is_int( $option ) ) { $term = get_term_by( 'id', $option, $this->get_name() ); } else { - $term = get_term_by( 'name', $option, $this->get_name() ); + // Term names get escaped in WP. See sanitize_term_field. + $term = get_term_by( 'name', esc_attr( $option ), $this->get_name() ); if ( ! $term || is_wp_error( $term ) ) { $new_term = wp_insert_term( $option, $this->get_name() );