WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#11947 closed defect (bug) (fixed)

wpautop inserts line break elements in select element breaking XHTML 1.1 Strict compatibility

Reported by: akerem Owned by:
Milestone: 3.0 Priority: low
Severity: normal Version: 2.9.1
Component: Formatting Keywords: has-patch
Focuses: Cc:

Description

The wpautop function of Wordpress inserts line break elements (<br />) after option elements in a select element of a form, breaking XHTML 1.1 Strict compatibility.

The problem can be solved simply by adding option to $allblocks variable in formatting.php

A diff file is attached.

Attachments (2)

formatting.diff (898 bytes) - added by akerem 5 years ago.
Diff file for formatting.php
11947.patch (2.0 KB) - added by SergeyBiryukov 4 years ago.

Download all attachments as: .zip

Change History (10)

@akerem5 years ago

Diff file for formatting.php

comment:1 @akerem5 years ago

  • Cc akerem added

comment:2 @nacin5 years ago

  • Milestone changed from Unassigned to 3.0

comment:3 @dd325 years ago

Confirmed bug in trunk:

$in = "<select>
<option>Value</option>
</select>";

$out  = wpautop($in);

var_dump($out);

?> 
string '<select>
<option>Value</option><br />
</select>
' (length=48)

Results after:

string '<select>
<option>Value</option>
</select>
' (length=48)

Note: If anyone is confused, that patch is reversed, Its the addition of option, not the removal.. had me perplexed for a moment there.

comment:4 @dd325 years ago

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

(In [13903]) Dont pee on <option>. Prevents the addition of a <br/> following a </option>. Props akerem. Fixes #11947

comment:5 follow-up: @WraithKenny4 years ago

  • Cc Ken@… added
  • Keywords changed from wpautop, line break, form, select, option to wpautop line break, form, select, option
  • Resolution fixed deleted
  • Status changed from closed to reopened

(Tested on 3.3-aortic-dissection)

The PHP version is fixed, but not the JavaScript version (Everyone always forgets the poor JavaScript version). Try in HTML Tab:

<select>
	<option>Value</option>
	<option>Value</option>   
	<option>Value</option>
	<option>Value</option> 
	<option>Value</option> 
</select>

Then switch to Visual and Back. The result is:

<select> <option>Value</option></select>
<select> <option>Value</option></select>
<select> <option>Value</option></select>
<select> <option>Value</option></select>
<select> <option>Value</option></select>

There are other fixes (I'm sure) that got applied to the php wpautop, but not the JavaScript version. Sadly, TinyMCE's reputation might be taking a beating over stuff like this ;-)

comment:6 @WraithKenny4 years ago

  • Keywords changed from wpautop line break, form, select, option to wpautop line break form, select, option

related #18514

@SergeyBiryukov4 years ago

comment:7 in reply to: ↑ 5 @SergeyBiryukov4 years ago

  • Keywords has-patch added; wpautop line break form select option removed
  • Milestone changed from 3.0 to 3.3

Replying to WraithKenny:

The PHP version is fixed, but not the JavaScript version

In 11947.patch I've synchronized block tags between formatting.php and editor.dev.js, which fixes the issue with <select>.

Isn't it better to open a new ticket for it though? I was under impression that tickets from a completed milestone generally shouldn't be reopened.

comment:8 @SergeyBiryukov4 years ago

  • Milestone changed from 3.3 to 3.0
  • Resolution set to fixed
  • Status changed from reopened to closed

Opened #18534 for synchronizing block tags.

Closing as fixed for 3.0.

Note: See TracTickets for help on using tickets.