Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 63ffe90

Browse files
committed
fix vulnerability when serving /client/... files
1 parent 71e39cc commit 63ffe90

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

runtime/src/server/middleware/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ export function serve({ prefix, pathname, cache_control }: {
106106
const cache: Map<string, Buffer> = new Map();
107107

108108
const read = dev
109-
? (file: string) => fs.readFileSync(path.resolve(build_dir, file))
110-
: (file: string) => (cache.has(file) ? cache : cache.set(file, fs.readFileSync(path.resolve(build_dir, file)))).get(file)
109+
? (file: string) => fs.readFileSync(path.join(build_dir, file))
110+
: (file: string) => (cache.has(file) ? cache : cache.set(file, fs.readFileSync(path.join(build_dir, file)))).get(file)
111111

112112
return (req: Req, res: Res, next: () => void) => {
113113
if (filter(req)) {
114114
const type = lookup(req.path);
115115

116116
try {
117-
const file = decodeURIComponent(req.path.slice(1));
117+
const file = path.posix.normalize(decodeURIComponent(req.path));
118118
const data = read(file);
119119

120120
res.setHeader('Content-Type', type);

0 commit comments

Comments
 (0)