Opened 11 years ago
Closed 11 years ago
#11372 closed Bug (fixed)
Special characters are encoded twice in nested editables
Reported by: | vAx | Owned by: | Piotrek Koszuliński |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.3.2 |
Component: | UI : Widgets | Version: | |
Keywords: | Cc: |
Description (last modified by )
Using åäö and alike in the caption gets converted to ä but so does the & part so if you take a look at the source it looks lite this: ä
to reproduce this just go to http://ckeditor.com/demo#widgets and the image tool heading, change the "Apollo CMS-LM spacecraft" caption to include ä for example then take a look at the source.
TC
- Open image2 sample.
- Paste "åäö" into the caption.
- Switch between modes twice.
- In wysiwyg you get "åäö".
Change History (10)
comment:1 Changed 11 years ago by
Component: | General → UI : Widgets |
---|---|
Description: | modified (diff) |
Keywords: | image2 removed |
Milestone: | → CKEditor 4.3.2 |
Status: | new → confirmed |
Summary: | using åäö in the caption, enhanced image plugin → Special characters in caption are encoded twice in nested editables |
Version: | 4.3.1 |
comment:2 Changed 11 years ago by
Summary: | Special characters in caption are encoded twice in nested editables → Special characters are encoded twice in nested editables |
---|
comment:3 Changed 11 years ago by
comment:4 Changed 11 years ago by
Owner: | set to Olek Nowodziński |
---|---|
Status: | confirmed → assigned |
comment:5 Changed 11 years ago by
Status: | assigned → review |
---|
Pushed solution to t/11372 (+test branch).
It turned out to be much more complex than expected:
- The problem was that, because of applyToAll used in entities plugin to solve #11250,
dataFilter
rule was executed twice: for all editor contents and for nested editable. Double execution implied double replacement:return text.replace( baseEntitiesRegex, getChar ).replace( entitiesRegex, getEntity );
- To avoid re-writing
dataFilter
logic from scratch (it's a matter of time though), I introducedexcludeNestedEditable
option so that filtering and replacement are done only once, for nested editable only, while filtering of editor contents excludes nested editables.
- Surprisingly, I realized that despite of
excludeNestedEditable
the problem still occured. It was because filtering defined in Entities plugin was executed in between two toDataFormat listeners of different priorities (8 and 13) in Widget plugin. Those listeners, designed to downcast but to preservedata-cke-*
attributes for the "target filtering", precisely the first one, downcasted nested editables, which madeexcludeNestedEditable
unaware of the "history" of parsed element and incapable of protecting its contents.
I postponed downcasting of nested editables and put it into the second
toDataFormat
listener, which seems to be harmless (at least tests pass).
comment:6 Changed 11 years ago by
Status: | review → review_failed |
---|
A rule:
addRules( {...}, { excludeNestedEditable: true } )
will be applied to all elements in:
<div><p contenteditable="true">x</p></div>
That's because isRuleApplicable
makes assumption that context.nestedEditable
may be true only if context.nonEditable
is true. They should be independent to avoid weird situations like the one above.
comment:7 Changed 11 years ago by
Owner: | changed from Olek Nowodziński to Piotrek Koszuliński |
---|---|
Status: | review_failed → assigned |
DUP closed #11391.
comment:8 Changed 11 years ago by
Status: | assigned → review |
---|
Pushed t/11372 branches. They contain additional tests and fix for issue mentioned in comment:6.
comment:9 Changed 11 years ago by
Status: | review → review_passed |
---|
comment:10 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
git:d138ae0 landed in master (18501ac tests).
I believe that I wrote tests against doubled encoding. So this is not a widget's only issue - most likely it's a conflict with the entities plugin.