Text content of <pre> element with attributes is removed when changing the formatting
|Reported by:||rcaliman||Owned by:||garry.yao|
|Component:||Core : Styles||Version:||3.0 Beta|
When trying to alter the formatting of a <pre> block that has attributes (like "class", "style", etc.) the text is removed from the editor.
Steps to reproduce:
- Go to CKeditor and switch to "Source" mode
- Paste <pre style="color: green">This is a bug.</pre>
- Switch back to "WYSIWYG" mode
- Select the text "This is a bug"
- Click the formatting dropdown and select "Heading 1"
The text is removed from the editor.
The text should change to new formatting and not be removed.
Bug cause & solution:
The issue comes from a regular expression that doesn't check for attributes of <pre> elements. It is found in CKEditor's styles plugin.
splitedHtml.replace( /<pre>([\s\S]*?)<\/pre>/gi, ...
splitedHtml.replace( /<pre[\s\S]*?>([\s\S]*?)<\/pre>/gi ...
Change History (6)
Changed 7 years ago by garry.yao
comment:3 Changed 7 years ago by garry.yao
- Keywords Confirmed Review? added; HasPatch removed
- Owner set to garry.yao
- Status changed from new to assigned