Opened 7 years ago

Closed 7 years ago

#5128 closed Bug (fixed)

Text content of <pre> element with attributes is removed when changing the formatting

Reported by: rcaliman Owned by: garry.yao
Priority: Normal Milestone: CKEditor 3.3
Component: Core : Styles Version: 3.0 Beta
Keywords: Confirmed Review+ Cc:


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:

  1. Go to CKeditor and switch to "Source" mode
  2. Paste <pre style="color: green">This is a bug.</pre>
  3. Switch back to "WYSIWYG" mode
  4. Select the text "This is a bug"
  5. 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.

file: _source/plugins/styles/plugin.js
line: 770
method: splitIntoPres()

splitedHtml.replace( /<pre>([\s\S]*?)<\/pre>/gi, ...

splitedHtml.replace( /<pre[\s\S]*?>([\s\S]*?)<\/pre>/gi ...

Attachments (1)

5128.patch (514 bytes) - added by garry.yao 7 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 7 years ago by alfonsoml

  • Keywords HasPatch added

comment:2 Changed 7 years ago by fredck

  • Milestone set to CKEditor 3.3

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

Thanks rcaliman for the bug report and the patch.
This should have been fixed earlier.

comment:4 Changed 7 years ago by alfonsoml

  • Keywords Review+ added; Review? removed

comment:5 Changed 7 years ago by garry.yao

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

Fixed with [5257].

Note: See TracTickets for help on using tickets.
© 2003 – 2016 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy