Skip to content
Browse files

Fixed exception caused by encoded backslash

See CLJ-870 and Compojure issue 47.
  • Loading branch information...
1 parent 02eb726 commit 4850168f28108c5837d5326d14b6443f74c11070 @weavejester committed Jan 7, 2012
Showing with 5 additions and 6 deletions.
  1. +3 −5 src/clout/core.clj
  2. +2 −1 test/clout/test/core.clj
View
8 src/clout/core.clj
@@ -2,7 +2,7 @@
"Library for parsing the Rails routes syntax."
(:require [clojure.string :as string])
(:import java.util.Map
- java.net.URLDecoder))
+ [java.net URLDecoder URLEncoder]))
;; Regular expression utilties
@@ -30,10 +30,8 @@
([path]
(path-decode path "UTF-8"))
([path encoding]
- (string/replace
- path
- #"(?:%[0-9A-Fa-f]{2})+"
- #(URLDecoder/decode % encoding))))
+ (-> (string/replace path "+" (URLEncoder/encode "+" encoding))
+ (URLDecoder/decode encoding))))
(defn- assoc-vec
"Associate a key with a value. If the key already exists in the map, create a
View
3 test/clout/test/core.clj
@@ -35,7 +35,8 @@
(deftest urlencoded-keywords
(are [path uri params] (= (route-matches path (request :get uri)) params)
"/:x" "/foo%20bar" {:x "foo bar"}
- "/:x" "/foo+bar" {:x "foo+bar"}))
+ "/:x" "/foo+bar" {:x "foo+bar"}
+ "/:x" "/foo%5Cbar" {:x "foo\\bar"}))
(deftest same-keyword-many-times
(are [path uri params] (= (route-matches path (request :get uri)) params)

0 comments on commit 4850168

Please sign in to comment.
Something went wrong with that request. Please try again.