From 57098cae6539f4b0555c24103d70affceef1da9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E4=B8=B0?= Date: Mon, 11 Sep 2017 17:36:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?program=E2=80=98s=20name=20con't=20start=20?= =?UTF-8?q?with=20".",=20=20"/".=20-if=20program=E2=80=98s=20name=20start?= =?UTF-8?q?=20with=20".",=20=20"/".=20=20this=20program=20con't=20be=20del?= =?UTF-8?q?ete.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/js/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/res/js/index.js b/res/js/index.js index 022ed0c..d22d251 100644 --- a/res/js/index.js +++ b/res/js/index.js @@ -207,7 +207,20 @@ $(function() { $("#formNewProgram").submit(function(e) { var url = "/api/programs", - data = $(this).serialize(); + data = $(this).serialize(), + name = $(this).find("[name=name]").val(), + disablechars = "./\\"; + + + console.log(name) + if (!name) { + alert("\"" + name + "\" is empty ") + return false + } + if (disablechars.indexOf(name[0]) != -1) { + alert("\"" + name + "\" Can't starts with \".\" \"/\" \"\\\"") + return false + } $.ajax({ type: "POST", url: url, From 06f60bcbbd502d98e90df54293a4a71204e21253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E4=B8=B0?= Date: Mon, 25 Sep 2017 11:23:51 +0800 Subject: [PATCH 2/2] remove console --- res/js/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/res/js/index.js b/res/js/index.js index d22d251..e4b848a 100644 --- a/res/js/index.js +++ b/res/js/index.js @@ -211,8 +211,6 @@ $(function() { name = $(this).find("[name=name]").val(), disablechars = "./\\"; - - console.log(name) if (!name) { alert("\"" + name + "\" is empty ") return false