0

I'm using CKEDITOR 4 for my own website. recently, I noticed when I am editing my post, if there are HTML codes, it just prints as HTML. If the code was:

<code language-html ...>
    <h1>Helloworld</h1>
    <p>This is the post!</p>
</code>

I expected see: enter image description here

But the result is really weird: enter image description here

only I can imagine is CKEDITOR read the HTML code, and parse it. I removed CKEDITOR to normal "textarea" tag, and there was no problem (code tag contains h1, p).

I searched on the Google and find some solutions, but nothing worked to me. Most I found was set the config above:

config.entities = false;
config.basicEntities = false;
config.entities_greek = false;
config.entities_latin = false;
config.entities_additional = '';
config.htmlEncodeOutput = false;

Still not working. Can anyone know about this issue?

p.s. I am using express framework as the server, and using jade template engine. I escaped the content when print: textarea#txtLog (name='log')!{log.text}

Dmitry Shvedov
  • 3,169
  • 4
  • 39
  • 51
modernator
  • 4,341
  • 12
  • 47
  • 76

1 Answers1

0

Use

htmlspecialchars($your_content, ENT_QUOTES, "UTF-8")

where you are displaying your post content after fetching it from the database.

Sachin
  • 1,646
  • 3
  • 22
  • 59
  • i said: 'i am using express framework as the server, and using jade template engine' :( – modernator Feb 23 '16 at 07:16
  • Oh OK, then you need such similar function in your framework or template engine. I suggested in context to PHP. Sorry. – Sachin Feb 23 '16 at 15:01