Make WordPress Core

Opened 18 years ago

Closed 17 years ago

Last modified 15 months ago

#3492 closed defect (bug) (fixed)

Visual Rich Editor wipes out various CSS class or style attributes

Reported by: figcar's profile figcar Owned by:
Milestone: 2.5 Priority: high
Severity: major Version: 2.3
Component: TinyMCE Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description (last modified by foolswisdom)

To replicate nasty bug behavior:

  1. Create a WP Page or Post with the following table code:
    <table>
    <tr><td>First row</td></tr>
    <tr class="even"><td>Second row</td></tr>
    <tr><td>Third row</td></tr>
    <tr class="even"><td>Fourth row</td></tr>
    <tr><td>Fifth row</td></tr>
    </table>
    
  1. With Visual Rich Editor (VRE) enabled, open the page for editing. Wait for VRE to load... Don't change anything. Just click "Save".
  1. VRE seems to cause the rows with a class specified -- and all their data -- to be removed (poof!), leaving this:
    <table>
    <tr><td>First row</td></tr>
    <tr><td>Third row</td></tr>
    <tr><td>Fifth row</td></tr>
    </table>
    

Use case: I'll often use a class on table rows for applying background color (from the stylesheet) to alternate rows for tabular data.

I've observed this VRE behavior on both Mac/Firefox and WinXP/IE6.

Attachments (3)

patch.txt (865 bytes) - added by framm 18 years ago.
Fixed Regular Expression for editor_plugin.js
editor_plugin.js (24.7 KB) - added by derjohng 17 years ago.
benchmark20071109.txt (887 bytes) - added by derjohng 17 years ago.

Download all attachments as: .zip

Change History (17)

#1 @foolswisdom
18 years ago

  • Description modified (diff)

#2 @foolswisdom
18 years ago

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

Closing as INVALID

class is considered unsafe, so only allowed when posted by trusted roles (admin , editor). This is not specific to the RTE.

figcar, thank you for participating in WordPress! You did not include the version of WordPress, and other env info, which are essential when reporting bugs.

#3 @Viper007Bond
18 years ago

  • Milestone 2.2 deleted

@framm
18 years ago

Fixed Regular Expression for editor_plugin.js

#4 @framm
18 years ago

  • Component changed from Administration to TinyMCE
  • Keywords has-patch added
  • Resolution invalid deleted
  • Status changed from closed to reopened

The response by "foolswisdom" does not make sense and must be due to a misunderstanding, maybe because the bug was not clearly marked as being a TinyMCE bug.

The bug occurs when you work on a post with any attribute on a TR tag (not just class), and the bug occurs in any role (not just non-trusted roles).

This bug persists in the current SVN version. It is due to the following line (249) in wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js:

content = content.replace(new RegExp('</tr>.*?<(tr|/table)>', 'mg'), '</tr><$

This tries to remove lint between a closing </tr> and the next opening <tr>, but does not allow for any attributes on the opening <tr>; if the opening <tr> carries a "class" or other attribute, then everything up to the next attribute-less <tr> or the closing </table> will be wiped.

The solution is slightly changing the Regex; patch attached.

#5 @foolswisdom
18 years ago

  • Milestone set to 2.4 (future)
  • Version set to 2.3

#6 @foolswisdom
18 years ago

  • Severity changed from normal to major

#7 @novasource
18 years ago

  • Summary changed from Visual Rich Editor wipes out table rows where a CSS class is specified to Visual Rich Editor wipes out various CSS class or style attributes

This also happens with <li> tags. If I have <li style="...">, it gets reverted to <li>.

#8 @flurischt
18 years ago

Same problem with <pre> Tag. Is use it in combination with the WP Plugin Google Syntax Highlighter and it strips my <pre name="code" class="php"> tags.

#9 @novasource
18 years ago

  • Keywords has-patch removed
  • Priority changed from normal to high

The included patch does not address all types of attribute loss, so removing has-patch keyword.

Suggesting high priority because of how pervasive this problem is.

#10 @derjohng
17 years ago

I had the same problems as flurischt.
So, I tried to modify the editor_plugin.js. I thought I have solved <pre name="code" class="php"> and foolswisdom's table tags problem.

And <li style="..."> problem, according to ticket:4667, it's not allowed.

benchmark20071109.txt is the file that I had tested. But, I am not sure this can "address all types of attribute loss" :p

Please try it and let me known whether this works well or not.

#11 @thee17
17 years ago

  • Keywords has-patch 2nd-opinion added

#12 @thee17
17 years ago

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

Using the newest trunk and TinyMCE 3.0 cannot reproduce closing as fixed.

#13 @Nazgul
17 years ago

  • Milestone 2.5 deleted

#14 @Nazgul
17 years ago

  • Milestone set to 2.5

Oops, wrong ticket.

Note: See TracTickets for help on using tickets.