Welcome Guest, Not a member yet? Register   Sign In
set_value - entities in default value double encoded
#1

[eluser]Unknown[/eluser]
Hi,
I have noticed that HTML entities in default value passed as a second parameter to set_value() are double encoded. I think there should be third parameter allowing to choose wheter second parameter should be passed to form_prep function, because sometimes it's useful, but in my case it's not. Look at the example (let's say there are no POST data, so look only at second parameter):
Code:
<input type="text" name="field" value="<?=set_value('field', 'coffee&tv;')?>" />
set_value returns "coffee&tv" and it is good.
But here is what I want:
Code:
<input type="text" name="2nd_field" value="<?=set_value('2nd_field', 'coffee&tv')?>" />
Again, I would expect that set_value returned "coffee&tv", but now it returns "coffee$amp;amp;tv", so the value I see in the browser is "coffee&tv". I think it would be better if htmlspecialchars in form helper would be called with $double_encode parameter set to false or if there would be a third parameter to set_value. Let me know what do you think.
#2

[eluser]vrencianz[/eluser]
I tested your example with CI 2.1.0

Code:
class Welcome extends CI_Controller
{
function index()
{
  $this->load->helper('form');
  echo set_value('2nd_field', 'coffee&tv');
}
}

and the result is (view page source in firefox) 'coffee&tv' and the page shows 'coffee&tv;'.

Maybe you are using an older codeigniter version?




Theme © iAndrew 2016 - Forum software by © MyBB