入力データをフィルタするPHPでは、関数 htmlspecialcharsとmysql_real_escape_stringを使用しています。 nodejsにはこのような関数はありますか?nodejsフィルタリング入力
xssのようなハッカーの攻撃を防ぐために、私のラウンドター機能のすべての入力をチェックする必要があります。 ありがとう!
入力データをフィルタするPHPでは、関数 htmlspecialcharsとmysql_real_escape_stringを使用しています。 nodejsにはこのような関数はありますか?nodejsフィルタリング入力
xssのようなハッカーの攻撃を防ぐために、私のラウンドター機能のすべての入力をチェックする必要があります。 ありがとう!
node-validatorは、このための完全なライブラリである、それは例えば、検証および衛生/フィルタリングの両方のために多くの機能を持っています
entityDecode() //Decode HTML entities
entityEncode()
xss() //Remove common XSS attack vectors from text (default)
xss(true) //Remove common XSS attack vectors from images
または
contains(str)
notContains(str)
regex(pattern, modifiers) //Usage: regex(/[a-z]/i) or regex('[a-z]','i')
notRegex(pattern, modifiers)
len(min, max) //max is optional
isUUID(version) //Version can be 3 or 4 or empty, see http://en.wikipedia.org/wiki/Universally_unique_identifier
isDate() //Uses Date.parse() - regex is probably a better choice
isAfter(date) //Argument is optional and defaults to today
isBefore(date) //Argument is optional and defaults to today
isIn(options) //Accepts an array or string
Google Caja HTML sanitizerのNodeJSパッケージがあります。それはあなたが使用しているライブラリに依存SQLについて
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
、それらのほとんどは、パラメータ化クエリをエスケープします:それとも、答えはhereを提供します。
をありがとうございました。そのライブラリにPHPのようなstrip_tags関数がありますか? – Erik
私はそれを見ませんでしたが、ここでは 'function strip_tags(oldString){ return oldString.replace(/(<([^>)+)>)/ ig、" "); } ' – alessioalex