c# - Which is the best way to Prevent Bad word entry in Discussion module in my site -
in web site hackers entering bad words. best way prevent this?
i using asp.net, c# , sql server resources.
- check bad words in form backend ?
- check bad words in javascript?
- check bad words in stored procedure before insert?
i think first method best.
please tell optimized code check
now using method
var filterwords = ["fool", "dumb", "couch potato"]; // "i" ignore case , "g" global var rgx = new regexp(filterwords.join(""), "gi"); function wordfilter(str) { return str.replace(rgx, "****"); } // call function document.write("original string - "); document.writeln("you fool. why dumb <br/>"); document.write("replaced string - "); document.writeln(wordfilter("you fool. why dumb"));
reality can’t prevent 100% of bad words. i’d go two-step verification on server side (js can disabled , sql not suitable handling this)
create list of common bad words used – catch 80% of inputs.
create list of patterns suspects signal manually verify these.
this patterns such as
- a) word contains 2 or more ** characters
- b) word contains letters , 1 of following characters 0,3,$, , others
in time you’ll have keep both lists updated. again, not solve 100% of cases catch , fix 95% if implemented properly.
Comments
Post a Comment