Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Ensure only hexadecimal percent codes are decoded
This continues the intent of #8, and ensures that only hexadecimal
percent codes are decoded, with anything else ignored.
  • Loading branch information
henrikblomkvist committed Feb 1, 2023
commit 19d6a1109f7d800281cfad28e8d77f0f36447daf
2 changes: 1 addition & 1 deletion src/ring/util/codec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
(percent-decode encoded "UTF-8"))
([^String encoded ^String encoding]
(str/replace encoded
#"(?:%[A-Za-z0-9]{2})+"
#"(?:%[A-Fa-f0-9]{2})+"
(fn [chars]
(-> (parse-bytes chars)
(String. encoding)
Expand Down
2 changes: 1 addition & 1 deletion test/ring/util/test/codec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(is (= (percent-encode "foo") "%66%6F%6F")))

(deftest test-percent-decode
(is (= (percent-decode "%s/") "%s/"))
(is (= (percent-decode "%s4/") "%s4/"))
(is (= (percent-decode "%20") " "))
(is (= (percent-decode "foo%20bar") "foo bar"))
(is (= (percent-decode "foo%FE%FF%00%2Fbar" "UTF-16") "foo/bar"))
Expand Down