Skip to content

Commit 0f0eef7

Browse files
committed
Fix partial query-string decoding bug
This aligns Ring form parameter parsing to adhere to the encoding scheme defined by: https://url.spec.whatwg.org/#urlencoded-parsing Fixes #524.
1 parent fe1ba59 commit 0f0eef7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ring-core/src/ring/middleware/params.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[ring.util.request :as req]))
66

77
(defn- parse-params [params encoding]
8-
(let [params (codec/form-decode params encoding)]
8+
(let [params (codec/form-decode-map params encoding)]
99
(if (map? params) params {})))
1010

1111
(defn- assoc-param-map [req k v]

ring-core/test/ring/middleware/test/params.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
(is (empty? (:form-params resp)))
1313
(is (= {"foo" "bar" "biz" "bat%"} (:params resp)))))
1414

15+
(deftest wrap-params-partial-query-params
16+
(let [req {:query-string "foo"}
17+
resp (wrapped-echo req)]
18+
(is (= {"foo" ""} (:query-params resp)))))
19+
1520
(deftest wrap-params-query-and-form-params
1621
(let [req {:query-string "foo=bar"
1722
:headers {"content-type" "application/x-www-form-urlencoded"}

0 commit comments

Comments
 (0)