From 242efb0a240bb29338266028a3c0b9f8bbb5e0a9 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 14 Aug 2017 05:58:23 +0000 Subject: [PATCH] Widgets: Suppress PHP warnings raised by `DOMDocument::loadHTML()` in `WP_Widget_Text::is_legacy_instance()` which could appear in Text widget forms. Also explicitly use HTML5 doctype when parsing Text widget contents in legacy mode detection. Amends [41050]. See #40951. Fixes #41622. git-svn-id: https://develop.svn.wordpress.org/trunk@41251 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/widgets/class-wp-widget-text.php | 4 ++-- tests/phpunit/tests/widgets/text-widget.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/widgets/class-wp-widget-text.php b/src/wp-includes/widgets/class-wp-widget-text.php index e6d979347d..ef9e349aa4 100644 --- a/src/wp-includes/widgets/class-wp-widget-text.php +++ b/src/wp-includes/widgets/class-wp-widget-text.php @@ -116,8 +116,8 @@ class WP_Widget_Text extends WP_Widget { } $doc = new DOMDocument(); - $doc->loadHTML( sprintf( - '%s', + @$doc->loadHTML( sprintf( + '%s', esc_attr( get_bloginfo( 'charset' ) ), $instance['text'] ) ); diff --git a/tests/phpunit/tests/widgets/text-widget.php b/tests/phpunit/tests/widgets/text-widget.php index 6c7ec1f102..9bc6edcad4 100644 --- a/tests/phpunit/tests/widgets/text-widget.php +++ b/tests/phpunit/tests/widgets/text-widget.php @@ -397,6 +397,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { // Check text examples that will not migrate to TinyMCE. $legacy_text_examples = array( '', + '
Quote
Citation
', '', "", '',