#16341Entities entered in wysiwyg are decoded and therefore gone when toggling to html source or saving
Description
Version info: 1.4.1 demo mode with some adaptions in page tsconfig
If you want to use the RTE for documentation purposes, you might need to talk about entities, but they get decoded when toggling to htmlCode view and on save.
- in whysiwyg enter <
- toggle to htmlCode view and you see < where it should be <
- toggle back whysiwyg and you see <
The same destructive behaviour is observed on
- entering < in wysiwyg-mode
- then pressing save
I found out where this happens :-)
The thief of my entitities is to be found in HTMLArea.htmlEncode = function(str). Before the entities get encoded, they get decoded:
str = HTMLArea.htmlDecode(str);
If you comment out this line, the entities are kept, provided that the parser is configured properly (see additional information).
Prosit, Uschi
HTMLArea.htmlEncode = function(str) {
if (typeof(str) != ‘string’) str = str.toString(); // we don’t need regexp for that, but.. so be it for now.
// Let’s not do it twice
// str = HTMLArea.htmlDecode(str);
str = str.replace(/&/g, “&”);
str = str.replace(//g, “>”);
str = str.replace(/\xA0/g, “ “); // Decimal 160, non-breaking-space
str = str.replace(/\x22/g, “”“); // \x22 means ‘”‘
str = str.replace(HTMLArea.Reg_entities, “&$1;”); // keep numeric entities
return str;
};
Parser configuration:
- default, see res/proc/pageTSConfig.txt
RTE.default.proc.entryHTMLparser_db.htmlSpecialChars = 0
## my config
# If this is not set, the entities are destroyed by the central parser even after
# you comment out the str = HTMLArea.htmlDecode(str);
RTE.default.proc.exitHTMLparser_rte = 1
RTE.default.proc.exitHTMLparser_rte.htmlSpecialChars = -1
(issue imported from #M3830)
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.