Welcome Guest, Not a member yet? Register   Sign In
Sanitizing Form inputs form quotes (' and ")
#1

Hi,

I was facing an issue where, if I post characters like single quote ( ' ) or double quote( " ) as a form input field, and due to some validation failure.. if I want the form to retain those values, it was showing garbage values like ' for single quote and " for double quote.

I tried many things like accessing form fields from $this->input->post instead of $_POST, enabling XSS filtering in config, using $this->security->xss_clean(), etc, but nothing helped.

Finally, I went to "system\helpers\form_helper.php" and changed the function form_input at line number 171 to following -

PREVIOUS : $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => $value);

CHANGED: $defaults = array('type' => 'text', 'name' => (( ! is_array($data)) ? $data : ''), 'value' => html_entity_decode($value, ENT_QUOTES, 'UTF-8'));

And this seemed to be working fine so far.
I want to know if this is correct way to achieve what I want.

Thanks.
Reply


Messages In This Thread
Sanitizing Form inputs form quotes (' and ") - by sujit510 - 12-30-2014, 05:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB