exposed mapping for unreserved characters

original commit: 1f02a0a8b8
This commit is contained in:
John Clements 2012-11-01 12:37:34 -07:00
parent 191874f50f
commit 7c864d188f
2 changed files with 17 additions and 1 deletions

View File

@ -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?]{ @defproc[(uri-userinfo-decode [str string?]) string?]{
Decodes a string according to the rules in @cite["RFC3986"] for the userinfo field. 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?]{ @defproc[(form-urlencoded-encode [str string?]) string?]{

View File

@ -69,7 +69,17 @@
(uri-userinfo-decode "hello") => "hello" (uri-userinfo-decode "hello") => "hello"
(uri-userinfo-decode "hello%20there") => "hello there" (uri-userinfo-decode "hello%20there") => "hello there"
(uri-userinfo-decode "hello:there") => "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 ;; tests adapted from Noel Welsh's original test suite