CodeIgniter Forums

Full Version: validation class esaping bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

line 663 in validation.php
return str_replace(array("'", '"', '<', '>'), array("'", "&quot;", '&lt;', '&gt;'), stripslashes($str));

There shouldn't be a stripslashes there right?

El Forum

Yes why is strip slashes there? If magic quotes is off (as it should be) then stripslashes can create undesireable results.

E.g. if I am writing a message board where user can type code examples, if someone types \" or \' or \\ it shouldn't come back as " or ' or \ if there is an error in the form. This is especially problematic in CI 1.7.0 where strip slashes is applied to $_POST so you don't have access to the original unmodified values that were submitted unless you save them before doing a $this->form_validation->run().