Jump to content

htmlspecialchars and javascript injection


fohanlon

Recommended Posts

Hi Guys

 

I have only realised that it is possible to injection javascript <script> tags in form fields.

 

I read that htmlspecialchars will solve this by encoding < as %lt; etc.

 

However, I cannot get the function to work.  Does utf-8 encoding have an effect on the function?

 

Thanks for the help

 

Fergal.

 

Looked at the csource and yes it is in entity form.

 

I was trying to ensure that if a user enters something like <script>alert("test")</script> in a form field that on submission of the form the alert box will not work.  The form will not write anything to a database, variables are jsut gathered and emailed in the mail function.

 

Am I right using htmlspecialchars.  I have spent hours reading forums etc and am confused.

 

Thanks,

 

Fergal.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.