WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 years ago

#43815 closed defect (bug) (fixed)

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

Reported by: jeherve Owned by: pento
Milestone: 5.1 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 4 years ago.
Text Widget: suppress all warnings thrown when using invalid HTML in legacy mode

Download all attachments as: .zip

Change History (5)

@jeherve
4 years ago

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

#1 @westonruter
4 years ago

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

👍

#2 @pento
3 years ago

  • Milestone changed from 5.0 to 5.1

#3 @pento
3 years ago

  • Owner changed from westonruter to pento
  • Status changed from accepted to assigned

#4 @pento
3 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 44578:

Widgets: Don't log invalid HTML in the Text Widget.

[41215] supresses these irrelevant error messages from the front end, this removes them from the error log, too.

Props jeherve.
Fixes #43815.

Note: See TracTickets for help on using tickets.