views:

93

answers:

2

Is there a .Net library which everyone uses to validate/cleanup user input from website. It seems like there are a lot of posts explaining which regex people use and when. While I do like to reinvent the wheel quite frequently I draw the line at user input.

Mostly I am not worried about SQL injection, but rather am concerned about html inputs and inputs which I cannot imagine. It would just put a smile on my face for it to work like this:

    string sanitizedInput = InputSanitizer.SanitizeInput(input, SanitizeOption.RemoveHTML 
| SanitizeOption.RemoveSQL);

Anyone have anything like this? (Thanks in advance)

+4  A: 

The latest version of AntiXSS has HTML sanitization functions that MS use internally.

blowdart
See http://davidhayden.com/blog/dave/archive/2009/09/19/MicrosoftAntiCrossSiteScriptingLibrary31.aspx for a quick tip / micro-overview.
Jesper Mortensen
A: 

There's xVal:

http://www.codeplex.com/xval

and the Validator toolkit:

http://mvcvalidatortoolkit.codeplex.com/

klabranche