From 3190e7c6eb774bad0f10e16ad873a4ca81535a04 Mon Sep 17 00:00:00 2001 From: Romain Calascibetta Date: Tue, 6 Apr 2021 17:46:56 +0200 Subject: [PATCH] Disallow @ on scheme part --- lib/uri.ml | 2 +- lib_test/test_runner.ml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/uri.ml b/lib/uri.ml index d19f927..20c049a 100644 --- a/lib/uri.ml +++ b/lib/uri.ml @@ -892,7 +892,7 @@ module Parser = struct let scheme = lift (fun s -> Some (Pct.decode (Pct.cast_encoded s))) - (take_while (fun c -> c <> ':' && c <> '/' && c <> '?' && c <> '#') + (take_while (fun c -> c <> '@' && c <> ':' && c <> '/' && c <> '?' && c <> '#') <* char ':') <|> return None diff --git a/lib_test/test_runner.ml b/lib_test/test_runner.ml index a8ed8e7..d4cf38b 100644 --- a/lib_test/test_runner.ml +++ b/lib_test/test_runner.ml @@ -422,6 +422,9 @@ let test_with_change = [ let urn = Uri.of_string "urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6" in let urn2= Uri.with_scheme urn (Some "urn") in assert_equal ~printer urn urn2; + let git = Uri.of_string "git@github.com:owner/repo" in + let pp_option pp ppf = function Some x -> Format.fprintf ppf "%a" pp x | None -> () in + assert_equal ~printer:(Format.asprintf "%a" (pp_option Format.pp_print_string)) (Uri.scheme git) None ; let urn_path = Uri.with_path Uri.empty "uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6"