#3492 closed defect (bug) (fixed)
Visual Rich Editor wipes out various CSS class or style attributes
Reported by: |
|
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 )
To replicate nasty bug behavior:
- 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>
- With Visual Rich Editor (VRE) enabled, open the page for editing. Wait for VRE to load... Don't change anything. Just click "Save".
- 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)
Change History (17)
#4
@
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.
#7
@
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
@
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
@
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
@
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.
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.