asp.net - Client validation that acts the same as .NET page validator/XSS prevention? -


i've got free text form people submit feedback/support requests. people past in support ticket or error log contains triggers .net page validator xss attempt. takes user error page if site choked on input.

preferably, i'd rather have page client-side validation when press save button before it's submitted.

is there regex or method can hook same basic check on client side, or have write regex disallows characters < , >?

.net 4.0's internal crosssitescriptingvalidation uses isdangerousstring method match on these conditions:

if occurrence of < or & @ end of post data, it's safe. if < followed a-z, a-z, /, ?, or ! it's unsafe. if & followed #(octothorpe!) it's unsafe.

this regex in javascript should work:

/^(?!(.|\n)*<[a-z!\/?])(?!(.|\n)*&#)(.|\n)*$/i 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -