File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 125125 ([x encoding]
126126 (form-encode* x encoding)))
127127
128+ (defn- form-encoded-chars? [^String s]
129+ (or (.contains s " +" ) (.contains s " %" )))
130+
128131(defn form-decode-str
129132 " Decode the supplied www-form-urlencoded string using the specified encoding,
130133 or UTF-8 by default."
131134 ([encoded]
132135 (form-decode-str encoded " UTF-8" ))
133- ([^String encoded ^String encoding]
134- (try
135- (URLDecoder/decode encoded ^String (or encoding " UTF-8" ))
136- (catch Exception _ nil ))))
136+ ([^String encoded encoding]
137+ (if (form-encoded-chars? encoded)
138+ (try
139+ (let [^String encoding (or encoding " UTF-8" )]
140+ (URLDecoder/decode encoded encoding))
141+ (catch Exception _ nil ))
142+ encoded)))
137143
138144(defn- tokenized [s delim]
139145 (reify clojure.lang.IReduceInit
You can’t perform that action at this time.
0 commit comments