Make WordPress Core

Opened 15 years ago

Closed 13 years ago

#11947 closed defect (bug) (fixed)

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

Reported by: akerem's profile 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 15 years ago.
Diff file for formatting.php
11947.patch (2.0 KB) - added by SergeyBiryukov 13 years ago.

Download all attachments as: .zip

Change History (10)

@akerem
15 years ago

Diff file for formatting.php

#1 @akerem
15 years ago

  • Cc akerem added

#2 @nacin
15 years ago

  • Milestone changed from Unassigned to 3.0

#3 @dd32
14 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.

#4 @dd32
14 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

#5 follow-up: @WraithKenny
13 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 ;-)

#6 @WraithKenny
13 years ago

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

related #18514

#7 in reply to: ↑ 5 @SergeyBiryukov
13 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.

#8 @SergeyBiryukov
13 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.