WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 6 years ago

#2992 closed defect (bug) (fixed)

HTML editor deletes rows (that have properties) from tables

Reported by: FireMotion Owned by:
Milestone: 2.5 Priority: high
Severity: major Version: 2.0
Component: TinyMCE Keywords: data-loss has-patch needs-testing
Focuses: Cc:

Description (last modified by foolswisdom)

Concerning tables: When rows have properties, and there are multiple rows in the table, all rows but the first will be deleted when you revisit the Code tab.

REPRO: always
STEPS:

  1. as admin (also confirmed with author, but stripping not deleting is appropriate then)
  2. In Write Post, click Code tab
  3. Enter
    <table>
      <tr class="toprow">
        <td>1</td>
        <td>2</td>
      </tr>
      <tr class="row2">
        <td>3</td>
        <td>4</td>
      </tr>
      <tr class="row3">
        <td>5</td>
        <td>6</td>
      </tr>
    </table>
    
  4. Click Save and Continue Editing or Visual tab
  5. Click Code tab

ACTUAL RESULT

<table>
	<tr class="toprow">
		<td>1</td>
		<td>2</td>
	</tr>
</table>

ADDITIONAL DETAILS
Apparently, because the <tr> tags have properties (in this case class, but originally I was using valign properties, even though they might not be official <tr> properties), only the first row is kept. It doesn't matter how many rows there are.

Attachments (1)

2992.diff (993 bytes) - added by Nazgul 7 years ago.

Download all attachments as: .zip

Change History (23)

comment:1 markjaquith8 years ago

Does your WP user have the unfiltered_html capability?

comment:2 firemotion8 years ago

Yes. (I checked it with an admin account AND I checked the wp_options database and wp_user_roles has unfiltered_html for Administrator enabled.)

As far as I know, this bug has been there ever since the TinyMCE was introduced (it was pretty much the only reason why I disabled it -- until I decided to look what triggered it).

comment:3 FireMotion8 years ago

  • Summary changed from HTML editor eats rows with properties from tables to HTML editor deletes rows (that have properties) from tables

comment:4 matt7 years ago

  • Milestone changed from 2.1 to 2.2

comment:5 foolswisdom7 years ago

  • Description modified (diff)
  • Keywords data-loss added
  • Milestone changed from 2.2 to 2.1
  • Severity changed from major to blocker

Confirmed bug.
ENV: WP 2.1-beta1 r4716

Updating ticket description.

comment:6 follow-up: miklb7 years ago

Does this relate to if I add <div class="something">blah, blah</div> in code view, it's converted to <p class="something">blah, blah with no closing </p>?

comment:7 in reply to: ↑ 6 miklb7 years ago

Replying to miklb:

Does this relate to if I add <div class="something">blah, blah</div> in code view, it's converted to <p class="something">blah, blah with no closing </p>?

I should add this is happening in 2.1 up through RC1.

comment:8 foolswisdom7 years ago

miklb, it would be great if you created a new ticket and mention this ticket.

comment:9 foolswisdom7 years ago

  • Milestone changed from 2.1 to 2.1.1

comment:10 Nazgul7 years ago

  • Milestone changed from 2.1.1 to 2.1.2

comment:11 foolswisdom7 years ago

  • Milestone changed from 2.1.3 to 2.2

comment:12 rob1n7 years ago

  • Component changed from Administration to TinyMCE

Still reproducible in r5269.

comment:13 Nazgul7 years ago

  • Keywords needs-patch added
  • Milestone changed from 2.2 to 2.4

comment:14 foolswisdom7 years ago

  • Milestone changed from 2.4 to 2.3

comment:15 rob1n7 years ago

  • Severity changed from blocker to major

comment:16 karmadude7 years ago

It looks like the following regular expression is causing the issue

wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js


cleanup: function(type, content) {

    ...

    case "get_from_editor":
        ...   
        //Handle table badness
        ...
        content = content.replace(new RegExp('</tr>.*?<(tr|/table)>', 'mg'), '</tr><$1>');

    ...

}

comment:17 karmadude7 years ago

Anyone figured out a resolution for this issue yet?

Nazgul7 years ago

comment:18 Nazgul7 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

comment:19 ryan7 years ago

  • Milestone changed from 2.3 to 2.4 (next)

Patch looks good, but let's wait until 2.4 to get it in.

comment:20 andy7 years ago

Patch is workable, though not perfect. I'd like to have it in 2.3.

comment:21 foolswisdom7 years ago

  • Milestone changed from 2.4 to 2.3

comment:22 thee176 years ago

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

I'm getting

<table _moz_resizing="true">
<tbody>
<tr class="toprow">
<td>1</td>
<td>2</td>
</tr>
<tr class="row2">
<td>3</td>
<td>4</td>
</tr>
<tr class="row3">
<td>5</td>
<td>6</td>
</tr>
</tbody></table>

Therefore marking as being fixed by TinyMCE 3.0

Note: See TracTickets for help on using tickets.