XSS_CLEAN not working in CodeIgniter

$this->input->post('question', TRUE)

Even if I add TRUE, it still allows people to add html code. Why is this?

+4
source share
1 answer

The xss_clean() function does not remove all HTML, it removes / replaces certain things that are considered dangerous, for example, <script> tags.

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

The XSS filter looks for common methods to run Javascript or other types of code that try to steal cookies or do other malicious things. If something is not allowed, it is safe by converting data into character objects.

Someone introducing a <p> to your page, or perhaps not desired, is actually not an effective attack. You will need to indicate what you want to do with it. In many cases, you will need the HTML output, which was xss_clean() ed.

It looks like you want either htmlspecialchars() or strip_tags() (note: these are two very different things). If you want to encode HTML, you can also use CI html_escape() :

 echo html_escape($this->input->post('question')); 

If you want to output HTML, not entities, just use the XSS filter yourself:

 echo $this->input->post('question', TRUE); echo xss_clean($user_input); 
+5
source

Source: https://habr.com/ru/post/1399584/


All Articles