mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: add code verefication
This commit is contained in:
parent
7ce058c4a5
commit
3b1641ca5f
1 changed files with 4 additions and 0 deletions
|
|
@ -187,6 +187,10 @@ export async function createServer() {
|
||||||
server.post('/page', async (request, reply) => {
|
server.post('/page', async (request, reply) => {
|
||||||
const body = request.body || {}
|
const body = request.body || {}
|
||||||
if (body.code) {
|
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 dir = 'resources/ChatGPTCache/page'
|
||||||
const filename = body.code + '.json'
|
const filename = body.code + '.json'
|
||||||
const filepath = path.join(dir, filename)
|
const filepath = path.join(dir, filename)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue