Cross-Site Scripting & sqlDataReader

V

vineetbatta

I am using sqlDataReader for Showing data from the Data base.
But if the Data from sql is having tags like <script>alert()</script> then it shows an alert box while binding.

Is there any way of suppressing it this ..... ???? or is it a flaw?

regards
Vineet Batta
 
K

Ken Schaefer

Use HTMLEncode() when outputting the data.

It replaces things like < with &lt; etc. It is not a bug - you are using
reserved characters in your text, and you need to replace those reserved
characters with the appropriate HTML Entities that are defined in the HTML
specifications. HTMLEncode() does this for you.

Cheers
Ken

: I am using sqlDataReader for Showing data from the Data base.
: But if the Data from sql is having tags like <script>alert()</script> then
it shows an alert box while binding.
:
: Is there any way of suppressing it this ..... ???? or is it a flaw?
:
: regards
: Vineet Batta
:
 
K

Ken Schaefer

You mean HTMLEncode()?

URLEncode() is for formatting text to be placed into a URL (eg as part of a
querystring)

Cheers
Ken

: use HttpServerUtility.UrlEncode while binding.
:
: Av.
: : >I am using sqlDataReader for Showing data from the Data base.
: > But if the Data from sql is having tags like <script>alert()</script>
then
: > it shows an alert box while binding.
: >
: > Is there any way of suppressing it this ..... ???? or is it a flaw?
: >
: > regards
: > Vineet Batta
: >
:
:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top