forked from defunkt/toes
Fix path normalization in safePath function
This commit is contained in:
parent
c081785d37
commit
e17580c366
|
|
@ -9,8 +9,9 @@ import type { Child } from 'hono/jsx'
|
||||||
const APPS_DIR = process.env.APPS_DIR!
|
const APPS_DIR = process.env.APPS_DIR!
|
||||||
|
|
||||||
const safePath = (base: string, ...segments: string[]) => {
|
const safePath = (base: string, ...segments: string[]) => {
|
||||||
const full = resolve(base, ...segments)
|
const norm = resolve(base)
|
||||||
if (!full.startsWith(base + '/') && full !== base) return null
|
const full = resolve(norm, ...segments)
|
||||||
|
if (!full.startsWith(norm + '/') && full !== norm) return null
|
||||||
return full
|
return full
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user