Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Exception when %5C is used in a url with route/resources #47

Closed
ibdknox opened this Issue · 2 comments

2 participants

@ibdknox

Hey James,

Running this code:

(use 'compojure.core 'compojure.route)
(defroutes x (GET "/" [] "blah") (resources "/"))
(x {:uri "/%5C" :request-method :get})

I get the following exception:

java.lang.StringIndexOutOfBoundsException: String index out of range: 1
nil
    at java.lang.String.charAt(String.java:686)
    at java.util.regex.Matcher.appendReplacement(Matcher.java:703)
    at clojure.string$replace_by.invoke(string.clj:58)
    at clojure.string$replace.invoke(string.clj:82)
    at clout.core$path_decode.invoke(core.clj:33)
    at clout.core$path_decode.invoke(core.clj:31)
    at clojure.core$map$fn__3811.invoke(core.clj:2430)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:466)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$map$fn__3815.invoke(core.clj:2435)
    at clojure.lang.LazySeq.sval(LazySeq.java:42)
    at clojure.lang.LazySeq.seq(LazySeq.java:60)
    at clojure.lang.RT.seq(RT.java:466)
    at clojure.core$seq.invoke(core.clj:133)
    at clojure.core$reduce.invoke(core.clj:5994)
    at clout.core$assoc_keys_with_groups.invoke(core.clj:56)
    at clout.core.CompiledRoute.route_matches(core.clj:86)
    at compojure.core$if_route$fn__437.invoke(core.clj:38)
    at compojure.core$if_method$fn_user=> _430.invoke(core.clj:24)
    at ring.middleware.file_info$wrap_file_info$fn__941.invoke(file_info.clj:40)
    at ring.middleware.content_type$wrap_content_type$fn__921.invoke(content_type.clj:18)
    at compojure.core$routing$fn__456.invoke(core.clj:98)
    at clojure.core$some.invoke(core.clj:2388)
    at compojure.core$routing.doInvoke(core.clj:98)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:602)
    at compojure.core$routes$fn__460.invoke(core.clj:103)
    at user$eval968.invoke(NO_SOURCE_FILE:15)
    at clojure.lang.Compiler.eval(Compiler.java:6465)
    at clojure.lang.Compiler.eval(Compiler.java:6431)
    at clojure.core$eval.invoke(core.clj:2795)
    at clojure.main$repl$read_eval_print__5967.invoke(main.clj:244)
    at clojure.main$repl$fn__5972.invoke(main.clj:265)
    at clojure.main$repl.doInvoke(main.clj:265)
    at clojure.lang.RestFn.invoke(RestFn.java:512)
    at user$eval27$acc__3869__auto____30$fn__32.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.AFn.run(AFn.java:24)
    at java.lang.Thread.run(Thread.java:680)
@weavejester
Owner

Hm, this would appear to be a bug in clojure.string/replace. It doesn't like replacing with a backslash if the matcher is a regular expression. For example:

(clojure.string/replace "x" #"." "\\")

I'll see about opening up an issue on it in Clojure, and I'll add a workaround into Clout so it'll work with current versions of Clojure.

@weavejester
Owner

Ah, looks like it's already been reported as CLJ-870.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.