Use consistent sanitization on tax classes (#41220)

This commit is contained in:
Barry Hughes 2023-11-10 11:40:18 -08:00 committed by GitHub
commit 8134a9237c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Use consistent sanitization when saving tax classes.

View File

@ -408,6 +408,14 @@ class WC_Admin_Post_Types {
}
}
if ( ! empty( $request_data['_tax_class'] ) ) {
$tax_class = sanitize_title( wp_unslash( $request_data['_tax_class'] ) );
if ( 'standard' === $tax_class ) {
$tax_class = '';
}
$product->set_tax_class( $tax_class );
}
$product->set_featured( isset( $request_data['_featured'] ) );
if ( $product->is_type( 'simple' ) || $product->is_type( 'external' ) ) {
@ -505,7 +513,7 @@ class WC_Admin_Post_Types {
}
if ( ! empty( $request_data['_tax_class'] ) ) {
$tax_class = wc_clean( wp_unslash( $request_data['_tax_class'] ) );
$tax_class = sanitize_title( wp_unslash( $request_data['_tax_class'] ) );
if ( 'standard' === $tax_class ) {
$tax_class = '';
}

View File

@ -546,7 +546,7 @@ class WC_Meta_Box_Product_Data {
'width' => isset( $_POST['variable_width'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_width'][ $i ] ) ) : '',
'height' => isset( $_POST['variable_height'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_height'][ $i ] ) ) : '',
'shipping_class_id' => isset( $_POST['variable_shipping_class'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_shipping_class'][ $i ] ) ) : null,
'tax_class' => isset( $_POST['variable_tax_class'][ $i ] ) ? wc_clean( wp_unslash( $_POST['variable_tax_class'][ $i ] ) ) : null,
'tax_class' => isset( $_POST['variable_tax_class'][ $i ] ) ? sanitize_title( wp_unslash( $_POST['variable_tax_class'][ $i ] ) ) : null,
)
);