Fixed the UTF8 and Space error
This commit is contained in:
parent
7bed7ba82f
commit
d39cbaa25b
|
@ -17,19 +17,21 @@ exports.form = function (req, res) {
|
|||
|
||||
if (/^([0-9a-f]{2}[:-]){5}([0-9a-f]{2})$/.exec(mac)) {
|
||||
if (action == "add") {
|
||||
if (label) {
|
||||
if(label.split('').length > 1) {
|
||||
console.log("add mac request mac: " +mac + " label " + label + " ip: " + ip);
|
||||
if (/^[0-9a-zA-Z]+$/.exec(label)) {
|
||||
snmpMac.add(mac, label, function (err) {
|
||||
snmpMac.add(mac, '"' + label + '"', function (err) {
|
||||
console.log("add mac result: " + err);
|
||||
req.flash('status', err == null ? "" : "database error: " + err);
|
||||
res.redirect("/db");
|
||||
});
|
||||
}
|
||||
} else {
|
||||
req.flash('status', 'label is invalid ("^[0-9a-zA-Z]+$")');
|
||||
res.redirect("/db");
|
||||
}
|
||||
} else if (action == "remove") {
|
||||
console.log("remove mac request mac: "+mac + " label " + label + " ip: " + ip);
|
||||
console.log("remove mac request mac: "+mac + " label " + '"' + label + '"' + " ip: " + ip);
|
||||
snmpMac.delete(mac, function (err) {
|
||||
console.log("delete mac result: " + err);
|
||||
req.flash('status', err == null ? "" : "database error: " + err);
|
||||
|
|
|
@ -109,7 +109,7 @@ app.use(express.static('public'));
|
|||
app.use(cookieParser());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(bodyParser.json({ extended: true }));
|
||||
app.use(cookieSession({secret: 'steam-stalker', cookie: {maxAge: 60000}}));
|
||||
app.use(cookieSession({secret: 'ctdo', cookie: {maxAge: 60000}}));
|
||||
app.use(flash());
|
||||
|
||||
app.set('/views');
|
||||
|
|
Loading…
Reference in New Issue