mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
fix path traversal attack
This commit is contained in:
+3
-1
@@ -1,10 +1,12 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||||
|
import { posix as pathPosix } from 'path'
|
||||||
|
|
||||||
import apiConfig from '../../config/api.json'
|
import apiConfig from '../../config/api.json'
|
||||||
|
|
||||||
|
const basePath = pathPosix.resolve('/', apiConfig.base)
|
||||||
const encodePath = (path: string) => {
|
const encodePath = (path: string) => {
|
||||||
const encodedPath = `${apiConfig.base}${path === '/' ? '' : path}`
|
const encodedPath = pathPosix.join(basePath, pathPosix.resolve('/', path))
|
||||||
if (encodedPath === '/' || encodedPath === '') {
|
if (encodedPath === '/' || encodedPath === '') {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user