0
我用下面的節點模塊,因爲我想,以防止XSS: https://github.com/chriso/node-validator對象有沒有方法在節點驗證模塊更換
str = str.replace(non_displayables[i], '');
^
TypeError: Object 0 has no method 'replace'
at remove_invisible_characters (C:\Users\Jack\Desktop\Dropbox\Nimble\node_mo
dules\validator\lib\xss.js:180:19)
我試圖清理以下信息並創建JSON對象:
var story = {
_id: sanitize(data._id).xss(), //string
title: sanitize(data.title).xss(), //string
deadline: sanitize(data.deadline).xss(), //date string
description: sanitize(data.description).xss(), //string
sp: sanitize(data.sp).xss(), //number
value: sanitize(data.value).xss(), //number
roi: sanitize(data.roi).xss(), //decimal number
type: sanitize(data.type).xss(), //string
lane: sanitize(data.lane).xss() //Typically 0
}
我包括我的代碼頂部的模塊:sanitize = require('validator').sanitize;
線178 - 1從模塊xss.js的83:
function remove_invisible_characters(str) {
for (var i in non_displayables) {
str = str.replace(non_displayables[i], '');
}
return str;
}
你的問題是什麼? –