Skip to content
Advertisement

When I save span with style to MySQL, style is deleted

I am using TinyMCE for my PHP/CodeIgniter CMS back-end input. However when I use a text color, some of codes are not saved and does not show the correct color.

How can I solve this problem?

Thanks in advance.

JavaScript

becomes

JavaScript

in database


Some codes are here.

In my controller.

JavaScript

And in my model.

JavaScript

Advertisement

Answer

With CodeIgniter, if you have the XSS filter enabled globally (set in your config.php) you will find that HTML inline style text is removed from all form inputs.

To get around this you can disable global XSS filtering and filter your TinyMCE form inputs manually with something like HTML Purifier, which gives you a lot more control over the elements and attributes which you would like to allow.

For the rest of your form inputs you can still run them through CodeIgniter’s XSS filter – you’ll just have to do it manually, like so:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement