Skip to content

Loading…

Fix for error thrown by double-escape when encoded dollar-sign is decoded. #3

Merged
merged 1 commit into from

2 participants

@jamieorc

util/codec.clj: fixed handling of $ in double-escape. Decoding of %24 into $ then caused index-out-of-bounds error as $ has special meaning
in regexes.

jamieorc util/codec.clj: fixed handling of $ in double-escape. Decoding of %24
into $ then caused index-out-of-bounds error as $ has special meaning
in regexes.
0d58eb9
@weavejester weavejester merged commit cf19f9e into ring-clojure:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 13, 2012
  1. util/codec.clj: fixed handling of $ in double-escape. Decoding of %24

    jamieorc committed
    into $ then caused index-out-of-bounds error as $ has special meaning
    in regexes.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +1 −1 ring-core/src/ring/util/codec.clj
  2. +2 −1 ring-core/test/ring/util/test/codec.clj
View
2 ring-core/src/ring/util/codec.clj
@@ -8,7 +8,7 @@
org.apache.commons.codec.binary.Base64))
(defn- double-escape [^String x]
- (.replace x "\\" "\\\\"))
+ (.replace (.replace x "\\" "\\\\") "$" "\\$"))
(defn percent-encode
"Percent-encode every character in the given string using either the specified
View
3 ring-core/test/ring/util/test/codec.clj
@@ -11,7 +11,8 @@
(deftest test-percent-decode
(is (= (percent-decode "%20") " "))
(is (= (percent-decode "foo%20bar") "foo bar"))
- (is (= (percent-decode "foo%FE%FF%00%2Fbar" "UTF-16") "foo/bar")))
+ (is (= (percent-decode "foo%FE%FF%00%2Fbar" "UTF-16") "foo/bar"))
+ (is (= (percent-decode "%24") "$")))
(deftest test-url-encode
(is (= (url-encode "foo/bar") "foo%2Fbar"))
Something went wrong with that request. Please try again.