From 824604870bfbd1092e4fa0adb79496d3714248db Mon Sep 17 00:00:00 2001 From: ZhuangYumin Date: Mon, 18 Dec 2023 01:19:06 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=AB=AF=EF=BC=8C=E9=98=B2=E6=AD=A2=E9=9D=9E=E6=B3=95=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E8=AF=B7=E6=B1=82=E5=8D=A1=E7=88=86=E5=90=8E=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/Web/index.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/frontend/Web/index.js b/frontend/Web/index.js index 6737462..18dfdff 100644 --- a/frontend/Web/index.js +++ b/frontend/Web/index.js @@ -46,7 +46,7 @@ async function GetResult(session_token,operation_token) { { if(message_map.get(session_token).has(operation_token)) { - const ret=message_map.get(session_token).get(operation_token); + let ret=message_map.get(session_token).get(operation_token); message_map.get(session_token).delete(operation_token); if(Validing=='True'){ if(!(await IsValid(ret))) @@ -144,12 +144,36 @@ io.on('connection', async (socket) => { const session_token=substrings[1]; if(head[1]=='O') { + if(msg.split('\n').length!=1) + { + console.log("O: input has "+msg.split('\n').length+" lines"); + socket.emit('response', "Invalid Input"); + return; + } SendRequest(msg); ret=await GetResult(session_token,"Init"); console.log("ret: "+ret); socket.emit('response', ret); } else{ + if(head[1]=='R') + { + if(msg.split('\n').length!=2) + { + console.log("R: input has "+msg.split('\n').length+" lines"); + socket.emit('response', "Invalid Input"); + return; + } + } + else + { + if(msg.split('\n').length!=1) + { + console.log("other: input has "+msg.split('\n').length+" lines"); + socket.emit('response', "Invalid Input"); + return; + } + } const operation_token=substrings[2]; const outhentication_key=substrings[3]; const command=msg.trim().split('\n')[1];