Skip to content

Commit

Permalink
do not String.trim on cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesm committed Oct 29, 2024
1 parent 8a36724 commit 5560685
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions middleware.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let cookie cookie_name (reqd : Httpaf.Reqd.t) =
let cookie_list = String.split_on_char ';' cookies in
List.find_opt
(fun cookie ->
let parts = String.trim cookie |> String.split_on_char '=' in
let parts = cookie |> String.split_on_char '=' in
match parts with
| [ name; _ ] -> String.equal name cookie_name
| _ -> false)
Expand Down Expand Up @@ -123,8 +123,8 @@ let http_response ~title ?(header_list = []) ?(data = "") reqd http_status =
Lwt.return_unit

let cookie_value cookie =
match String.split_on_char '=' (String.trim cookie) with
| _ :: s :: _ -> Ok (String.trim s)
match String.split_on_char '=' cookie with
| _ :: s :: _ -> Ok s
| _ -> Error (`Msg "Bad cookie")

let user_from_auth_cookie cookie users =
Expand Down

0 comments on commit 5560685

Please sign in to comment.