From 4b7b089896c966f61585db121242a1c79de425fa Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 18 Jun 2021 15:51:26 +0000 Subject: [PATCH] REST API: Decode single and double quote entities in widget names and descriptions. Follow-up to [51174], [51175]. Props ocean90, ramonopoly. Fixes #53407. git-svn-id: https://develop.svn.wordpress.org/trunk@51183 602fd350-edb4-49c9-b593-d223f7449a82 --- .../endpoints/class-wp-rest-widget-types-controller.php | 4 ++-- .../tests/rest-api/rest-widget-types-controller.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php index 59873974e0..9c0837644b 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php @@ -214,11 +214,11 @@ class WP_REST_Widget_Types_Controller extends WP_REST_Controller { $widget['is_multi'] = (bool) $widget_object; if ( isset( $widget['name'] ) ) { - $widget['name'] = html_entity_decode( $widget['name'] ); + $widget['name'] = html_entity_decode( $widget['name'], ENT_QUOTES, get_bloginfo( 'charset' ) ); } if ( isset( $widget['description'] ) ) { - $widget['description'] = html_entity_decode( $widget['description'] ); + $widget['description'] = html_entity_decode( $widget['description'], ENT_QUOTES, get_bloginfo( 'charset' ) ); } unset( $widget['callback'] ); diff --git a/tests/phpunit/tests/rest-api/rest-widget-types-controller.php b/tests/phpunit/tests/rest-api/rest-widget-types-controller.php index d19daebdad..6082931e42 100644 --- a/tests/phpunit/tests/rest-api/rest-widget-types-controller.php +++ b/tests/phpunit/tests/rest-api/rest-widget-types-controller.php @@ -206,17 +206,17 @@ class WP_Test_REST_Widget_Types_Controller extends WP_Test_REST_Controller_Testc $widget_id = 'archives'; wp_register_sidebar_widget( $widget_id, - 'Legacy ‑ Archive ‑ Widget', + '‘Legacy ‑ Archive ‑ Widget’', function() {}, array( - 'description' => 'A great & interesting archive of your site’s posts!', + 'description' => '“A great & interesting archive of your site’s posts!”', ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/widget-types/archives' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 'Legacy ‑ Archive ‑ Widget', $data['name'] ); - $this->assertSame( 'A great & interesting archive of your site’s posts!', $data['description'] ); + $this->assertSame( '‘Legacy ‑ Archive ‑ Widget’', $data['name'] ); + $this->assertSame( '“A great & interesting archive of your site’s posts!”', $data['description'] ); } /**