From 3b1641ca5f8a321ff3dda09b776eecd1dae77682 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Tue, 15 Aug 2023 21:41:52 +0800 Subject: [PATCH] fix: add code verefication --- server/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/index.js b/server/index.js index c70f79d..455363a 100644 --- a/server/index.js +++ b/server/index.js @@ -187,6 +187,10 @@ export async function createServer() { server.post('/page', async (request, reply) => { const body = request.body || {} if (body.code) { + const pattern = /^[a-zA-Z0-9]+$/ + if (!pattern.test(body.code)) { + reply.send({error: 'bad request'}) + } const dir = 'resources/ChatGPTCache/page' const filename = body.code + '.json' const filepath = path.join(dir, filename)