Sumeet Kashyap
Sumeet Kashyap

Reputation: 133

Codeigniter removes HTML entities

I have a form in codeigniter to save some html content to the database. Example this HTML:

<div style="width:400px">
  <div style="background-color:yellow">
    Header
  </div>
</div>

When i save it i get the html tags broken. Even if i "print_r" the $_POST on submitting the form i see the html tags broken. Here is what i get:

<div 
  <div 
    Header
  </div>
</div>

But the same form without codeigniter (simple code) works normal and shows proper html.

Is this normal in CI? How can this be solved?

Upvotes: 1

Views: 4879

Answers (2)

GautamD31
GautamD31

Reputation: 28763

Try to put "/" at style closing :

<div style="width:400px;">
    <div style="background-color:yellow;">
       Header
    </div>
</div>

Upvotes: 0

Taha Paksu
Taha Paksu

Reputation: 15616

It is a XSS filtering problem. On your CI installation, you have set the global_xss_filtering flag to true, therefore it cleanses all the input data before you can use it. here, the problem is described and solved before:

Codeigniter - Disable XSS filtering on a post basis

and here it is described in the "Security Filtering" section:

http://codeigniter.com/user_guide/libraries/input.html

Upvotes: 5

Related Questions