Skip to content

Commit 84cb2ee

Browse files
committed
Merge commit from fork
1 parent b5e63a3 commit 84cb2ee

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/serve-static.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const serveStatic = <E extends Env = any>(
111111
} else {
112112
try {
113113
filename = tryDecodeURI(c.req.path)
114-
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) {
114+
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}|\\/.test(filename)) {
115115
throw new Error()
116116
}
117117
} catch {

‎test/serve-static.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,11 @@ describe('Serve Static Middleware', () => {
384384

385385
const res3 = await request(server).get('/static//admin/secret.txt')
386386
expect(res3.status).toBe(404)
387+
388+
const res4 = await request(server).get('/static/admin%5Csecret.txt')
389+
expect(res4.status).toBe(404)
390+
expect(res4.headers['x-authorized']).toBeUndefined()
391+
expect(res4.text).not.toBe('secret')
387392
})
388393
})
389394

0 commit comments

Comments
 (0)