diff --git a/includes/admin/wc-admin-functions.php b/includes/admin/wc-admin-functions.php index be7dfa39a42..d56a72829c8 100644 --- a/includes/admin/wc-admin-functions.php +++ b/includes/admin/wc-admin-functions.php @@ -208,7 +208,7 @@ function wc_save_order_items( $order_id, $items ) { $item_data = array(); foreach ( $data_keys as $key => $default ) { - $item_data[ $key ] = isset( $items[ $key ][ $item_id ] ) ? wc_clean( wp_unslash( $items[ $key ][ $item_id ] ) ) : $default; + $item_data[ $key ] = isset( $items[ $key ][ $item_id ] ) ? wc_check_invalid_utf8( wp_unslash( $items[ $key ][ $item_id ] ) ) : $default; } if ( '0' === $item_data['order_item_qty'] ) { diff --git a/includes/wc-formatting-functions.php b/includes/wc-formatting-functions.php index 0d94c0e2a22..0c8d439b70a 100644 --- a/includes/wc-formatting-functions.php +++ b/includes/wc-formatting-functions.php @@ -377,6 +377,20 @@ function wc_clean( $var ) { } } +/** + * wp_check_invalid_utf8 with recursive array support. + * + * @param string|array $var Data to sanitize. + * @return string|array + */ +function wc_check_invalid_utf8( $var ) { + if ( is_array( $var ) ) { + return array_map( 'wc_check_invalid_utf8', $var ); + } else { + return wp_check_invalid_utf8( $var ); + } +} + /** * Run wc_clean over posted textarea but maintain line breaks. *