Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

form_input double escaping data why ? #2405

Closed
crustamet opened this issue Nov 14, 2019 · 3 comments
Closed

form_input double escaping data why ? #2405

crustamet opened this issue Nov 14, 2019 · 3 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@crustamet
Copy link
Contributor

crustamet commented Nov 14, 2019

hello i use this function form_input from the form helper like this, i don't know what i am doing wrong and don`t know if this is a bug or not but please test this.

$input_attrs = array();
$input_attrs['name'] = 'contact_name';
$input_attrs['type'] = 'text';
$input_attrs['value'] = set_value('contact_name');

echo form_input($input_attrs);

and when i put this value in the input

<script>alert("test")</script>

it returns this :

&amp;lt;script&amp;gt;alert(&amp;quot;test&amp;quot;)&amp;lt;/script&amp;gt;

instead of :

&lt;script&gt;alert(&quot;test&quot;)&lt;/script&gt;

But when i use without the form_input function and use it like this

<input type="text" name="contact_name" value="<?=set_value('contact_name')?>">

it returns good escaped data

&lt;script&gt;alert(&quot;test&quot;)&lt;/script&gt;
@crustamet crustamet added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 14, 2019
@crustamet
Copy link
Contributor Author

This was the worst thing happening in codeigniter 3 also :( horror stuff.. xD

This needs to end right ?

@lonnieezell
Copy link
Member

I'm a bit confused about how this is bad: &lt;script&gt;alert(&quot;test&quot;)&lt;/script&gt; and this is good <script>alert("test")</script>?

If someone is inputting a script in your form it should be caught and dealt with so that it does not execute when the form is redisplayed, or the data viewed. When the data is displayed in the input it is automatically escaped to make it safe. That's why you're seeing that.

@crustamet
Copy link
Contributor Author

Hello again, i edited the problem so you guys can check please take this error bug into consideration, because on all other platforms this works and on this does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

2 participants