Opened 15 years ago
Closed 15 years ago
#5128 closed Bug (fixed)
Text content of <pre> element with attributes is removed when changing the formatting
Reported by: | Razvan Caliman | Owned by: | Garry Yao |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 3.3 |
Component: | Core : Styles | Version: | 3.0 Beta |
Keywords: | Confirmed Review+ | Cc: |
Description
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"
Result:
The text is removed from the editor.
Expected:
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.
file: _source/plugins/styles/plugin.js
line: 770
method: splitIntoPres()
problem:
splitedHtml.replace( /<pre>([\s\S]*?)<\/pre>/gi, ...
solution:
splitedHtml.replace( /<pre[\s\S]*?>([\s\S]*?)<\/pre>/gi ...
Attachments (1)
Change History (6)
comment:1 Changed 15 years ago by
Keywords: | HasPatch added |
---|
comment:2 Changed 15 years ago by
Milestone: | → CKEditor 3.3 |
---|
Changed 15 years ago by
Attachment: | 5128.patch added |
---|
comment:3 Changed 15 years ago by
Keywords: | Confirmed Review? added; HasPatch removed |
---|---|
Owner: | set to Garry Yao |
Status: | new → assigned |
comment:4 Changed 15 years ago by
Keywords: | Review+ added; Review? removed |
---|
Thanks rcaliman for the bug report and the patch.
This should have been fixed earlier.