Ticket #4589 (closed Bug: expired)
Output style attribute "override" by regular expression is ignored
| Reported by: | pomu0325 | Owned by: | garry.yao |
|---|---|---|---|
| Priority: | Normal | Milestone: | CKEditor 3.2 |
| Component: | Core : Styles | Version: | 3.0 |
| Keywords: | Cc: |
Description
For example, following override setting unintendedly matches all <font> element whatever attribute it has.
config.fontSize_style =
{
element : 'span',
attributes : { 'class' : '#(size)' },
overrides : [ { element : 'font', attributes : { 'class' : /^foo/ } } ]
};
'CKEDITOR.tools.clone()' seems not to clone RegExp object properly at line.89 of styles/plugin.js
styleDefinition = CKEDITOR.tools.clone( styleDefinition );
After this line, regular expression is turned into , therefore it matches anything.
Attachments
Change History
comment:3 Changed 4 years ago by fredck
- Milestone set to CKEditor 3.2
The patch should be good for it.
comment:4 Changed 4 years ago by garry.yao
- Owner set to garry.yao
- Status changed from new to assigned
Beside the RegExp fix there, the array clone could be further simplified - Array is simply first class Object in JavaScript.
comment:6 follow-up: ↓ 7 Changed 3 years ago by alfonsoml
- Keywords Review- added; Review? removed
The RegExp part has been merged in [4774] from the 3.1.x branch, so that part isn't needed.
I've done a quick test and it seems that the behavior remains the same if the code for the Array object is removed. Maybe it was added due to problems with some browser? If no one finds problems with that I guess that it could be removed.
comment:7 in reply to: ↑ 6 Changed 3 years ago by garry.yao
- Status changed from assigned to closed
- Keywords Review- removed
- Resolution set to expired
Replying to alfonsoml:
The RegExp part has been merged in [4774] from the 3.1.x branch, so that part isn't needed.
The problem described at this ticket was fixed already by [4774].
...Maybe it was added due to problems with some browser?
It's not targeting a specific browser, just to make the array clone codes simpler.

It seems to be a side-effect of [3704], 'clone' method now doesn't clone RegExp properly.
reproduce
expected result
Only the <font> element which matches the regular expression should be overrided.
actual result
Although 'class="bar"' doesn't match the regular expression, it is also overrided.
This problem is simply avoided by just cloning RegExp object. Is there any reason RegExp should not be cloned??