WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#43815 accepted defect (bug)

Text Widget: Warnings thrown when using invalid HTML in legacy mode

Reported by: jeherve Owned by: westonruter
Milestone: 5.0 Priority: normal
Severity: normal Version: 4.9
Component: Widgets Keywords: has-patch
Focuses: Cc:

Description

Steps to reproduce the issue

  1. Start with a site running WP 4.7.10.
  2. Add a new Text Widget to your site with the following contents:
<img src="http://example.com/img.jpg" border="0" title="Example" /></a>
  1. Update to WP 4.9.5
  2. Notice the widget still there under Appearance > Widgets.
  3. Load your site's front end.
  4. In your logs, you should see the following warning:
[Suppressed] Warning: DOMDocument::loadHTML(): Unexpected end tag : a in Entity, line: 1 in /home/wpcom/public_html/wp-includes/widgets/class-wp-widget-text.php on line 129

This seems to happen because of the invalid HTML in the widget.

In #41622 and r41251, we suppressed those warnings. Unfortunately invalid HTML can still fill in logs. I think it would be nice if we could get rid of those warnings, with the attached patch.

Let me know what you think about this!

Attachments (1)

43815.diff (1.4 KB) - added by jeherve 2 months ago.
Text Widget: suppress all warnings thrown when using invalid HTML in legacy mode

Download all attachments as: .zip

Change History (2)

@jeherve
2 months ago

Text Widget: suppress all warnings thrown when using invalid HTML in legacy mode

#1 @westonruter
2 months ago

  • Milestone changed from Awaiting Review to 5.0
  • Owner set to westonruter
  • Status changed from new to accepted

👍

Note: See TracTickets for help on using tickets.