Make WordPress Core

Changeset 51183


Ignore:
Timestamp:
06/18/2021 03:51:26 PM (4 years ago)
Author:
SergeyBiryukov
Message:

REST API: Decode single and double quote entities in widget names and descriptions.

Follow-up to [51174], [51175].

Props ocean90, ramonopoly.
Fixes #53407.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php

    r51175 r51183  
    215215
    216216            if ( isset( $widget['name'] ) ) {
    217                 $widget['name'] = html_entity_decode( $widget['name'] );
     217                $widget['name'] = html_entity_decode( $widget['name'], ENT_QUOTES, get_bloginfo( 'charset' ) );
    218218            }
    219219
    220220            if ( isset( $widget['description'] ) ) {
    221                 $widget['description'] = html_entity_decode( $widget['description'] );
     221                $widget['description'] = html_entity_decode( $widget['description'], ENT_QUOTES, get_bloginfo( 'charset' ) );
    222222            }
    223223
  • trunk/tests/phpunit/tests/rest-api/rest-widget-types-controller.php

    r51174 r51183  
    207207        wp_register_sidebar_widget(
    208208            $widget_id,
    209             'Legacy ‑ Archive ‑ Widget',
     209            '‘Legacy ‑ Archive ‑ Widget’',
    210210            function() {},
    211211            array(
    212                 'description' => 'A great & interesting archive of your site’s posts!',
     212                'description' => '“A great & interesting archive of your site’s posts!”',
    213213            )
    214214        );
     
    216216        $response = rest_get_server()->dispatch( $request );
    217217        $data     = $response->get_data();
    218         $this->assertSame( 'Legacy ‑ Archive ‑ Widget', $data['name'] );
    219         $this->assertSame( 'A great & interesting archive of your site’s posts!', $data['description'] );
     218        $this->assertSame( '‘Legacy ‑ Archive ‑ Widget’', $data['name'] );
     219        $this->assertSame( '“A great & interesting archive of your site’s posts!”', $data['description'] );
    220220    }
    221221
Note: See TracChangeset for help on using the changeset viewer.