mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
fix(http_of_dir): do not url-encode paths with /
This commit is contained in:
parent
2ed9131bdc
commit
c6d5c9a40f
1 changed files with 4 additions and 4 deletions
|
|
@ -39,7 +39,7 @@ let human_size (x:int) : string =
|
|||
let header_html = "Content-Type", "text/html"
|
||||
let (//) = Filename.concat
|
||||
|
||||
let encode_path s = U.percent_encode s
|
||||
let encode_path s = U.percent_encode ~skip:(function '/' -> true|_->false) s
|
||||
|
||||
let is_hidden s = String.length s>0 && s.[0] = '.'
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ let serve ~config (dir:string) : _ result =
|
|||
dir (if S.is_ipv6 server then "[%s]" else "%s") config.addr config.port;
|
||||
if config.delete then (
|
||||
S.add_route_handler server ~meth:`DELETE
|
||||
S.Route.(string_urlencoded @/ return)
|
||||
S.Route.rest
|
||||
(fun path _req ->
|
||||
if contains_dot_dot path then (
|
||||
S.Response.fail_raise ~code:403 "invalid path in delete"
|
||||
|
|
@ -131,7 +131,7 @@ let serve ~config (dir:string) : _ result =
|
|||
);
|
||||
if config.upload then (
|
||||
S.add_route_handler_stream server ~meth:`PUT
|
||||
S.Route.(string_urlencoded @/ return)
|
||||
S.Route.rest
|
||||
~accept:(fun req ->
|
||||
match S.Request.get_header_int req "Content-Length" with
|
||||
| Some n when n > config.max_upload_size ->
|
||||
|
|
@ -161,7 +161,7 @@ let serve ~config (dir:string) : _ result =
|
|||
(fun _ _ -> S.Response.make_raw ~code:405 "upload not allowed");
|
||||
);
|
||||
S.add_route_handler server ~meth:`GET
|
||||
S.Route.(string_urlencoded @/ return)
|
||||
S.Route.rest
|
||||
(fun path req ->
|
||||
let full_path = dir // path in
|
||||
let mtime = lazy (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue