Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web-api): percent-decode before path-splitting #560

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/server/learnocaml_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,11 @@ let launch () =
Learnocaml_store.Server.get () >>= fun config ->
let callback conn req body =
let uri = Request.uri req in
let path = Uri.path uri in
let path = Stringext.split ~on:'/' path in
let path =
Uri.path uri |>
Uri.pct_decode |> (* %-decoding must happen before `/`-splitting *)
Stringext.split ~on:'/'
in
let path =
let rec clean = function
| [] | [_] as l -> l
Expand All @@ -605,7 +608,6 @@ let launch () =
in
clean path
in
let path = List.map Uri.pct_decode path in
let query = Uri.query uri in
let args = List.map (fun (s, l) -> s, String.concat "," l) query in
let use_compression =
Expand Down
Loading