Skip to content
Browse files

Paper over the URL-encoding problem in clojure.java.io

  • Loading branch information...
1 parent 8ada3f7 commit ad8ad0f585aa4ddfe6cc8435cc52e06d8033fdbc @trptcolin trptcolin committed
Showing with 5 additions and 4 deletions.
  1. +1 −1 src/koan_engine/checker.clj
  2. +1 −1 src/koan_engine/koans.clj
  3. +3 −2 src/koan_engine/util.clj
View
2 src/koan_engine/checker.clj
@@ -6,7 +6,7 @@
(:require [koan-engine.util :as u]))
(defn mk-answers [koan-resource]
- (into {} (u/try-read (resource koan-resource))))
+ (into {} (u/try-read (.getPath (resource koan-resource)))))
(defn replace-with [s k replacements]
(let [unreplaced-texts (split s (re-pattern (str "\\b" k "\\b")))]
View
2 src/koan_engine/koans.clj
@@ -4,7 +4,7 @@
;; TODO: Proper koan validation. Accept the path as an argument.
(defn ordered-koans [answer-path]
- (map first (u/try-read (resource answer-path))))
+ (map first (u/try-read (.getPath (resource answer-path)))))
(defn ordered-koan-paths [koan-root answer-path]
(map (fn [koan-name]
View
5 src/koan_engine/util.clj
@@ -1,6 +1,7 @@
(ns koan-engine.util
(:require [clojure.string :as s]
- [clojure.java.io :as io]))
+ [clojure.java.io :as io])
+ (:import [java.net URLDecoder]))
(defn version<
"< for Clojure's version map."
@@ -53,7 +54,7 @@
(map read-string (take 3 (s/split version-string #"[\.\-]")))))
(defn try-read [path]
- (when path (read-string (slurp path))))
+ (when path (read-string (slurp (URLDecoder/decode path)))))
(defmacro do-isolated [& forms]
`(binding [*ns* (create-ns (gensym "jail"))]

0 comments on commit ad8ad0f

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