ckeditor - Encoding of entities - no perfect solution? -


we use ckeditor plugin redmine (https://github.com/a-ono/redmine_ckeditor) , experience following problem:

as a-ono, dev of plugin, puts it: "there seems no perfect solution."

i found http://komlenic.com/246/encoding-entities-to-work-with-ckeditor-3/ , http://ckeditor.com/forums/support/inside-tries-create-paragraph#comment-54348 , additional information "forcesimpleampersand:true" config.entities_latin = false;, i'm not sure how proceed. in process of moving additional users redmine, it's quite show-stopper if not able post links or xml/html content (e.g. part of error report)

so goes out ckeditor pros. hints?

sorry looks plugin redmine broken. ckeditor has nothing here - can correctly read , write entities if data loaded correctly. if entities decoded or encoded after saving them database , loading them means backend broken. instead of touching ckeditor's options, totally fine default, backend should fixed (meaning plugin redmine or, less likely, redmine itself).

let's consider following case. want write in comment <xml> tag. html be:

<p>this tag: <code>&lt;xml&gt;</code>.</p> 

and returned editor.getdata() or what's posted server if automatic integration <textarea> used.

now, if (e.g. in demo):

editor.setdata( '<p>this tag: <code>&lt;xml&gt;</code>.</p>' ); 

everything totally fine. same content displayed:

loading data using editor.setdata()

however, many developers use integration of ckeditor <textarea>s and, unfortunately, not understand how works. let's load exact data stored in database textarea:

<textarea><p>this tag: <code>&lt;xml&gt;</code>.</p></textarea> 

if try read value of textarea javascript using textarea.value get:

<p>this tag: <code><xml></code>.</p> 

as can see, encoding of <xml> tag lost, because in html &lt; read <.

so need encode data once more before loading them textarea:

<textarea>&lt;p&gt;this tag: &lt;code&gt;&amp;lt;xml&amp;gt;&lt;/code&gt;.&lt;/p&gt;</textarea> 

see < characters become &lt;, encoded &lt; become &amp;lt;. assure entities correctly preserved when printing data html. see, has nothing ckeditor. , same applies displaying data created in ckeditor - encoding must preserved. if lost, means backend encodes or decodes data , should not.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -