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

do not String.trim on cookies #81

Merged
merged 1 commit into from
Oct 29, 2024
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
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
Loading