I've been unable to get the htmlEncodeOutput setting to work. Whether I retrieve the data from a form submission, jQuery's .val() (when the jquery adapter is attached) or CKEditor's editor.getData(), the HTML remains unencoded.
I've tried this on the site I'm developing using my slightly edited ckeditor and lots of plugins, on the same site without plugins, on an empty test site with brand-new basic CKEditor 4.4 download, and even on a CKEditor I created from a text area I inserted into this site's demo page's source using a debug console. ( Textarea had id "test", Javascript command: "CKEDITOR.replace("test", { htmlEncodeOutput: true });")
A less annoying way to test:
A less annoying way to test: go to http://ckeditor.com/demo. Select the standard or full-featured editor, doesn't matter. Using a debug console, run:
I get unencoded HTML in Chrome, Firefox, and IE. I would be interested to hear if anyone has a different experience or can explain this.
I figured out what's behind
I figured out what's behind this after fidding around with the CKEditor source. I thought I'd read in some StackOverflow question or forum post that htmlEncodeOutput also encoded the results from editor.getData() and from the jQuery adapter's val() function. That was out of date or I must have misread; It doesn't. On my site and on the demo page, if I use editor.updateElement(), the textarea is updated with encoded HTML.
The issue on my site is that I'm not using the form around the textarea directly, I'm using jQuery's serialize() method. This, of course, uses jQuery's val() method, which ignores htmlEncodeOutput. Is this purposeful or an oversight? It was quite confusing to me, at least.