WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

#16456 closed defect (bug) (fixed)

<input> is not a block-level element, should be removed from wpautop()

Reported by: ABTOP Owned by: nacin
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: Formatting Keywords: has-patch
Focuses: Cc:

Description

The brief explanation of the problem:
http://wordpress.org/support/topic/extra-in-get_the_password_form

Upon further investigation, I was able to determine that the culprit is actually the wpautop() function (file wp-includes/formatting.php), line 188 - $allblocks - as of wp3.1 RC3:

function wpautop($pee, $br = 1) {

	if ( trim($pee) === '' )
		return '';
	$pee = $pee . "\n"; // just to make things a little easier, pad the end
	$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
	// Space things out a little
	$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';

The output from get_the_password_form() goes through wpautop() and extra <br /> tags are inserted before each <input> tag.

I hope this is not a feature.

Attachments (2)

16456.patch (678 bytes) - added by SergeyBiryukov 3 years ago.
16456.2.patch (1.1 KB) - added by SergeyBiryukov 2 years ago.

Download all attachments as: .zip

Change History (11)

SergeyBiryukov3 years ago

comment:1 SergeyBiryukov3 years ago

  • Keywords has-patch added; password extra brake tags in get_the_password_form wpautop removed

comment:2 nacin3 years ago

  • Keywords 3.2-early added
  • Milestone changed from Awaiting Review to Future Release

Kinda funky, but patch looks proper.

comment:3 SergeyBiryukov3 years ago

  • Keywords 3.2-early removed
  • Milestone changed from Future Release to 3.3

comment:4 nacin2 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 3.3 to Future Release
  • Summary changed from Extra brake tags in get_the_password_form() output to <input> is not a block-level element, should be removed from wpautop()

After IRC discussion, this approach isn't right.

Rather, the line breaks are due to input being considered a block-level element. this is wrong.

See #3054 for where this occurred.

Since this is so edge (doesn't even result in bad HTML) and technically requires a more comprehensive fix for something changed 5 or 6 years ago — instant punt.

SergeyBiryukov2 years ago

comment:5 SergeyBiryukov2 years ago

  • Keywords has-patch needs-unit-tests added; needs-patch removed

comment:6 nacin2 years ago

  • Milestone changed from Future Release to 3.4

comment:7 SergeyBiryukov2 years ago

Closed #19934 as duplicate.

comment:8 kurtpayne2 years ago

  • Cc kpayne@… added
  • Keywords needs-unit-tests removed

Unit test changeset 560 tests for this.

comment:9 nacin2 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [20078]:

<input> is not a block-level element; do not treat it like one in wpautop(). props SergeyBiryukov. props kurtpayne for the unit test. fixes #16456.

Note: See TracTickets for help on using tickets.