fix: ensure we decode uri encoded filenames
This commit is contained in:
parent
278a39a47b
commit
55f45b4e5b
3 changed files with 8 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@andyburke/serverus",
|
||||
"description": "A flexible HTTP server for mixed content. Throw static files, markdown, Typescript and (hopefully, eventually) more into a directory and serverus can serve it up a bit more like old-school CGI.",
|
||||
"version": "0.12.4",
|
||||
"version": "0.12.5",
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": "./serverus.ts",
|
||||
|
|
|
@ -279,7 +279,7 @@ export default async function handle_static_files(request: Request, server: SERV
|
|||
}
|
||||
|
||||
const url = new URL(request.url);
|
||||
const normalized_path = path.resolve(path.normalize(url.pathname).replace(/^\/+/, ''));
|
||||
const normalized_path = path.resolve(path.normalize(decodeURIComponent(url.pathname)).replace(/^\/+/, ''));
|
||||
|
||||
// if they're requesting something outside the working dir, just bail
|
||||
if (!normalized_path.startsWith(Deno.cwd())) {
|
||||
|
|
|
@ -321,9 +321,12 @@ Deno.test({
|
|||
put_body.delete('file');
|
||||
test_file = undefined;
|
||||
|
||||
const get_response = await fetch(`http://${test_server_info.hostname}:${test_server_info.port}/files/2Q==(30).txt`, {
|
||||
method: 'GET'
|
||||
});
|
||||
const get_response = await fetch(
|
||||
`http://${test_server_info.hostname}:${test_server_info.port}/files/${encodeURIComponent('2Q==(30).txt')}`,
|
||||
{
|
||||
method: 'GET'
|
||||
}
|
||||
);
|
||||
|
||||
asserts.assert(get_response.ok);
|
||||
asserts.assert(get_response.body);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue