PHP에서 입력 데이터를 필터링하기 위해 나는 htmlspecialchars와 mysql_real_escape_string 함수를 사용합니다. nodejs에 이와 같은 함수가 있습니까?nodejs 필터링 입력
해커가 xss와 같은 공격을하지 않도록 내 rounter 함수의 모든 입력을 확인해야합니다. 감사합니다.
PHP에서 입력 데이터를 필터링하기 위해 나는 htmlspecialchars와 mysql_real_escape_string 함수를 사용합니다. nodejs에 이와 같은 함수가 있습니까?nodejs 필터링 입력
해커가 xss와 같은 공격을하지 않도록 내 rounter 함수의 모든 입력을 확인해야합니다. 감사합니다.
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