Blacklist the XSS characters

Last post 07-03-2008 1:07 AM by Hong-Gang Chen - MSFT. 3 replies.

Sort Posts:

  • Blacklist the XSS characters

    06-30-2008, 7:26 AM
    • Member
      1 point Member
    • Suneelkk
    • Member since 01-08-2008, 11:42 AM
    • Posts 7

    Hi,

    In my site i wanted to blacklist the XSS characte3rs '<' '>' etc.

    For this i am using REgularExpressionValidator.

    I can use the whitelisting approach... by setting the

    ValidationExpression = @"^[a-zA-Z0-9#$!@^&%. ,\+_\-[\]\(\)\*\`\;\:]+$".

    But i am forced to use the black listing because i have to support unicode characters in mu controls.

    Can anybody suggest me what could be the ValidationExpression.

  • Re: Blacklist the XSS characters

    06-30-2008, 7:46 AM
    • All-Star
      63,218 point All-Star
    • TATWORTH
    • Member since 02-04-2003, 1:34 PM
    • England
    • Posts 12,351
    • TrustedFriends-MVPs

     Are you able to validate server-side?If so a server-side whilelist is far better as it can be rigourously unit tested.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Blacklist the XSS characters

    06-30-2008, 7:49 AM
    • Member
      1 point Member
    • Suneelkk
    • Member since 01-08-2008, 11:42 AM
    • Posts 7

    I am doing the server side validation also... but i want to validate at the client side also

  • Re: Blacklist the XSS characters

    07-03-2008, 1:07 AM
    Answer

    Suneelkk:

    I am doing the server side validation also... but i want to validate at the client side also

    Hi friend,

    I suggest you use "CustomValidator" to solve you problem.

    To know more about CustomValidator, please check this link, the link will tell you how to validate on both site.

    http://msdn.microsoft.com/de-de/library/system.web.ui.webcontrols.customvalidator.aspx

    Hope it helps,

    Hong Gang

    Hong-Gang Chen
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (4 items)