Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to HTML special chars using the xmlhttp.open?

Tags:

javascript

php

Please bear with me as I am a newbie programmer. Is their a way that HTML special chars can be used in call as this one: xmlhttp.open("POST","login/login.php",true); because when I check my URL adding this

/%22%3E%3Cscript%3Ealert('hacked')%3C/script%3E

turns

/"><script>alert('hacked')</script>

that somebody says my website can be exploit.

Can somebody help me or link a to similar question ?

Thanks in advance.

like image 551
shiro Jacinto Avatar asked Aug 23 '26 10:08

shiro Jacinto


1 Answers

Use javascript encodeURIComponent when passing parameters in your ajax request, this will properly encode the user data.

Read here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent

like image 52
VMcreator Avatar answered Aug 25 '26 22:08

VMcreator