Commit d39cbaa2 authored by fionera's avatar fionera

Fixed the UTF8 and Space error

parent 7bed7ba8
......@@ -17,19 +17,21 @@ exports.form = function (req, res) {
if (/^([0-9a-f]{2}[:-]){5}([0-9a-f]{2})$/.exec(mac)) {
if (action == "add") {
console.log("add mac request mac: "+mac + " label " + label + " ip: " + ip);
if (/^[0-9a-zA-Z]+$/.exec(label)) {
snmpMac.add(mac, label, function (err) {
console.log("add mac result: " + err);
req.flash('status', err == null ? "" : "database error: " + err);
res.redirect("/db");
});
if (label) {
if(label.split('').length > 1) {
console.log("add mac request mac: " +mac + " label " + label + " ip: " + ip);
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');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment