Opened 10 years ago

Closed 10 years ago

#12263 closed Task (fixed)

Improvements to style handling in default Paste from Word filter

Reported by: Olek Nowodziński Owned by: Olek Nowodziński
Priority: Normal Milestone: CKEditor 4.4.4
Component: Plugin : Paste from Word Version:
Keywords: Cc:

Description

Following PR https://github.com/ckeditor/ckeditor-dev/pull/116.


In default filter's addStyle the following optimization is performed:

this.attributes.style = styleText.replace( /^;|;(?=;)/, '' );

https://github.com/ckeditor/ckeditor-dev/blob/2752fb2d1f93f4c26630a8e830c52cc541657deb/plugins/pastefromword/filter/default.js#L89

Still, I managed to reproduce a case (http://tests.ckeditor.dev:1030/tests/tickets/9456/1), which isn't entirely covered by that RegExp as it either removes leading ";" OR redundant ";;":

;;font-family:calibri;font-size:medium 

will produce

;font-family:calibri;font-size:medium 

because RegExp is satisfied by removing leading ";".

While I'm not sure whether it really matters if some leading ";" remains, I'm for the use of CKEDITOR.tools.normalizeCssText() instead of any (even improved) RegExp to avoid any (further) problems and make sure styles are properly normalized.

Change History (4)

comment:1 Changed 10 years ago by Olek Nowodziński

Owner: set to Olek Nowodziński
Status: newassigned
Type: BugTask

comment:2 Changed 10 years ago by Olek Nowodziński

Status: assignedreview

Pushed improved code to branch:t/12263.

comment:3 Changed 10 years ago by Piotrek Koszuliński

Using tools.normalizeStyleText may lead to unpredictable behaviour changes, because this function completely parses and rebuilds style text. This is too far for a change that it's not based on any real scenario. I'll remove this commit and leave only initial PR, because it will be safe.

comment:4 Changed 10 years ago by Piotrek Koszuliński

Resolution: fixed
Status: reviewclosed

I changed the regexp a little bit so it consumes multiple leading semicolons properly. Fixed on master with git:18c6781.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy