From 0208d62579763eae00c47e1a11da69c7018f1139 Mon Sep 17 00:00:00 2001 From: Swrup Date: Tue, 8 Mar 2022 18:48:12 +0100 Subject: [PATCH] fix int_of_string on input --- src/permap.ml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/permap.ml b/src/permap.ml index 25db0f9..e4a54f2 100644 --- a/src/permap.ml +++ b/src/permap.ml @@ -269,13 +269,15 @@ let profile_post request = "Your display nick was updated!" | Error e -> render_unsafe e request ) | `Ok [ ("content", content); ("count", count); ("label", label) ] -> ( - let count = int_of_string count in - match User.update_metadata count label content nick with - | Ok () -> - Dream.respond ~status:`See_Other - ~headers:[ ("Location", "/profile") ] - "Your display nick was updated!" - | Error e -> render_unsafe e request ) + match int_of_string_opt count with + | None -> render_unsafe "Error: invalid count" request + | Some count -> ( + match User.update_metadata count label content nick with + | Ok () -> + Dream.respond ~status:`See_Other + ~headers:[ ("Location", "/profile") ] + "Your display nick was updated!" + | Error e -> render_unsafe e request ) ) | `Ok _ | `Many_tokens _ | `Missing_token _ | `Invalid_token _ | `Wrong_session _ | `Expired _ | `Wrong_content_type -> ( match%lwt Dream.multipart request with