diff --git a/collects/net/scribblings/uri-codec.scrbl b/collects/net/scribblings/uri-codec.scrbl index 6429b238f4..04a41496e2 100644 --- a/collects/net/scribblings/uri-codec.scrbl +++ b/collects/net/scribblings/uri-codec.scrbl @@ -86,6 +86,12 @@ Encodes a string according to the rules in @cite["RFC3986"] for the userinfo fie @defproc[(uri-userinfo-decode [str string?]) string?]{ Decodes a string according to the rules in @cite["RFC3986"] for the userinfo field. } +@defproc[(uri-unreserved-encode [str string?]) string?]{ +Encodes a string according to the rules in @cite["RFC3986"](section 2.3) for the unreserved characters. +} +@defproc[(uri-unreserved-decode [str string?]) string?]{ +Decodes a string according to the rules in @cite["RFC3986"](section 2.3) for the unreserved characters. +} @defproc[(form-urlencoded-encode [str string?]) string?]{ diff --git a/collects/tests/net/uri-codec.rkt b/collects/tests/net/uri-codec.rkt index 2517f6f43f..d6836e90d8 100644 --- a/collects/tests/net/uri-codec.rkt +++ b/collects/tests/net/uri-codec.rkt @@ -69,7 +69,17 @@ (uri-userinfo-decode "hello") => "hello" (uri-userinfo-decode "hello%20there") => "hello there" (uri-userinfo-decode "hello:there") => "hello:there" - + + ;; tried to choose characters from each subset: + (uri-encode "M~(@; ") => "M~(%40%3B%20" + (uri-path-segment-encode "M~(@; ") => "M~(@%3B%20" + (uri-userinfo-encode "M~(@; ") => "M~(%40;%20" + (uri-unreserved-encode "M~(@; ") => "M~%28%40%3B%20" + ;; matching decodes: + (uri-decode "M~(%40%3B%20") => "M~(@; " + (uri-path-segment-decode "M~(@%3B%20") => "M~(@; " + (uri-userinfo-decode "M~(%40;%20") => "M~(@; " + (uri-unreserved-decode "M~%28%40%3B%20") => "M~(@; " )) ;; tests adapted from Noel Welsh's original test suite