Fix path normalization in safePath function

This commit is contained in:
Chris Wanstrath 2026-03-01 22:37:46 -08:00
parent c081785d37
commit e17580c366

View File

@ -9,8 +9,9 @@ import type { Child } from 'hono/jsx'
const APPS_DIR = process.env.APPS_DIR!
const safePath = (base: string, ...segments: string[]) => {
const full = resolve(base, ...segments)
if (!full.startsWith(base + '/') && full !== base) return null
const norm = resolve(base)
const full = resolve(norm, ...segments)
if (!full.startsWith(norm + '/') && full !== norm) return null
return full
}