Skip to content

Commit 3490c5c

Browse files
authored
Merge pull request #33 from danielcompton/fix-nil-encoding
Fix nil argument regression in form-decode
2 parents d041adb + 5275c57 commit 3490c5c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/ring/util/codec.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
(form-decode-str encoded "UTF-8"))
127127
([^String encoded ^String encoding]
128128
(try
129-
(URLDecoder/decode encoded encoding)
129+
(URLDecoder/decode encoded ^String (or encoding "UTF-8"))
130130
(catch Exception _ nil))))
131131

132132
(defn form-decode

test/ring/util/test/codec.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353

5454
(deftest test-form-decode-str
5555
(is (= (form-decode-str "foo=bar+baz") "foo=bar baz"))
56-
(is (nil? (form-decode-str "%D"))))
56+
(is (nil? (form-decode-str "%D")))
57+
(is (= (form-decode-str "foo=bar+baz" nil) "foo=bar baz"))
58+
(is (= (form-decode-str "foo=bar+baz" "UTF-8") "foo=bar baz")))
5759

5860
(deftest test-form-decode
5961
(are [x y] (= (form-decode x) y)
@@ -75,4 +77,6 @@
7577
"a=%" {}
7678
"%=%" {}))
7779
(is (= (form-decode "a=foo%FE%FF%00%2Fbar" "UTF-16")
80+
{"a" "foo/bar"}))
81+
(is (= (form-decode "a=foo%2Fbar" nil)
7882
{"a" "foo/bar"})))

0 commit comments

Comments
 (0)