diff --git a/plugins/woocommerce-blocks/src/StoreApi/Utilities/NoticeHandler.php b/plugins/woocommerce-blocks/src/StoreApi/Utilities/NoticeHandler.php index 2f6ddc96173..a3bd2d5659b 100644 --- a/plugins/woocommerce-blocks/src/StoreApi/Utilities/NoticeHandler.php +++ b/plugins/woocommerce-blocks/src/StoreApi/Utilities/NoticeHandler.php @@ -34,7 +34,7 @@ class NoticeHandler { wc_clear_notices(); foreach ( $error_notices as $error_notice ) { - throw new RouteException( $error_code, $error_notice['notice'], 400 ); + throw new RouteException( $error_code, wp_strip_all_tags( $error_notice['notice'] ), 400 ); } } } diff --git a/plugins/woocommerce-blocks/tests/php/StoreApi/Utilities/NoticeHandler.php b/plugins/woocommerce-blocks/tests/php/StoreApi/Utilities/NoticeHandler.php new file mode 100644 index 00000000000..52aea2bf3df --- /dev/null +++ b/plugins/woocommerce-blocks/tests/php/StoreApi/Utilities/NoticeHandler.php @@ -0,0 +1,22 @@ +expectException( RouteException::class ); + $this->expectExceptionMessage( 'This is an error message with Some HTML in it.' ); + wc_add_notice( 'This is an error message with Some HTML in it.', 'error' ); + $errors = NoticeHandler::convert_notices_to_exceptions( 'test_error' ); + } +}