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

Commit

Permalink
fix vulnerability when serving /client/... files
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Mar 20, 2020
1 parent 71e39cc commit 63ffe90
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions runtime/src/server/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ export function serve({ prefix, pathname, cache_control }: {
const cache: Map<string, Buffer> = new Map();

const read = dev
? (file: string) => fs.readFileSync(path.resolve(build_dir, file))
: (file: string) => (cache.has(file) ? cache : cache.set(file, fs.readFileSync(path.resolve(build_dir, file)))).get(file)
? (file: string) => fs.readFileSync(path.join(build_dir, file))
: (file: string) => (cache.has(file) ? cache : cache.set(file, fs.readFileSync(path.join(build_dir, file)))).get(file)

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

try {
const file = decodeURIComponent(req.path.slice(1));
const file = path.posix.normalize(decodeURIComponent(req.path));
const data = read(file);

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

0 comments on commit 63ffe90

Please sign in to comment.