5

I have read Tinymce strips attributes on submit, TinyMce Allow all Html tag, TinyMCE valid elements: only allow specific CSS rules, how to prevent tinymce from stripping the 'style' attribute from input element?, TinyMCE, allow data attribute and many others...

But none of them work.

This is my code:

valid_elements : '+*[*]',
cleanup: false,
inline_styles : true

I have also tried

valid_elements : '*[*]'

(without + before *[*])

and even

valid_children : '+body[style]'

But when I add the styles manually like style="color: #fff;" and submit the form, TinyMCE removes the returned output.

In other words: I want TinyMCE to stop 'removing' any code automatically.

Community
  • 1
  • 1
Mohammad Naji
  • 5,372
  • 10
  • 54
  • 79

1 Answers1

11

No, it was not TinyMCE that was preventing inline styles.

CodeIgniter did that.

Even now that I had manually disabled XSS filtering using:

$body = $this->input('body', FALSE);

, that was still being removed because I had enabled XSS filtering in application/config/config.php:

$config['global_xss_filtering'] = TRUE;

But when I changed it to

$config['global_xss_filtering'] = FALSE;

the problem was resolved and I got rid of the Server Side filtering.


I post the answer here and I hope no one else be such crazy and mad that I became!

Mohammad Naji
  • 5,372
  • 10
  • 54
  • 79
  • 2
    You have no idea how much I love you for posting this! I just spent six hours working with this to try and figure it out and was just about to ask a question. So thank you thank you thank you! – zazvorniki Jul 23 '13 at 03:14
  • Very happy to see it is helping you `:)` – Mohammad Naji Jul 23 '13 at 07:02
  • Awesome! I spent countless hours scouring the Internet and TinyMCE posts everywhere to figure this out! One extra thing I had to do was to remove `xss_clean` from my validation rules as well! – Hamman Samuel May 09 '15 at 11:44