Skip to content

Commit af2e547

Browse files
committed
Backwards compability with 1.2.1
1 parent d2f2e5f commit af2e547

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

project.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
(defproject clojail "0.5.0"
22
:description "A sandboxing library."
3-
:dependencies [[clojure "1.3.0"]])
3+
:dependencies [[clojure "1.3.0"]]
4+
:dev-dependencies [[lein-multi "1.1.0-SNAPSHOT"]]
5+
:multi-deps {"1.2.1" [[clojure "1.2.1"]]})

src/clojail/core.clj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
val)
2323

2424
;; It sucks to have to deal with TimeUnits. They're so damned long.
25-
(def uglify-time-unit "Create a map of pretty keywords to ugly TimeUnits"
25+
(def ^{:doc "Create a map of pretty keywords to ugly TimeUnits"}
26+
uglify-time-unit
2627
(into {} (for [[enum aliases] {TimeUnit/NANOSECONDS [:ns :nanoseconds]
2728
TimeUnit/MICROSECONDS [:us :microseconds]
2829
TimeUnit/MILLISECONDS [:ms :milliseconds]
@@ -68,7 +69,10 @@
6869
(try (if-let [resolved (ns-resolve nspace s)]
6970
resolved
7071
s)
71-
(catch RuntimeException _ s)))
72+
;; Catching both of these exceptions appears to be necessary, because the exception that
73+
;; is thrown appears to be different depending on which version of Clojure you use.
74+
(catch RuntimeException _ s)
75+
(catch ClassNotFoundException _ s)))
7276

7377
(defn flatten-all
7478
"The core flatten doesn't flatten maps."
@@ -121,7 +125,9 @@
121125
(recurse form)))))))
122126

123127
;; Compose our earlier functions.
124-
(def ^{:private true} ensafen "Fix code to make interop safe."
128+
(def ^{:private true
129+
:doc "Fix code to make interop safe."}
130+
ensafen
125131
(comp dotify macroexpand-most))
126132

127133
(defn- mutilate

src/clojail/testers.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"Create a package object for putting in a tester."
88
[s] (Package/getPackage s))
99

10-
(def secure-tester-without-def "A tester that attempts to be secure, and allows def."
10+
(def ^{:doc "A tester that attempts to be secure, and allows def."}
11+
secure-tester-without-def
1112
#{'alter-var-root 'intern 'eval 'catch clojure.lang.Compiler
1213
'load-string 'load-reader 'addMethod 'ns-resolve 'resolve 'find-var
1314
'*read-eval* clojure.lang.Ref clojure.lang.Reflector 'ns-publics
@@ -20,5 +21,6 @@
2021
(p "java.util.concurrent")
2122
(p "java.awt")})
2223

23-
(def secure-tester "A somewhat secure tester. No promises."
24+
(def ^{:doc "A somewhat secure tester. No promises."}
25+
secure-tester
2426
(conj secure-tester-without-def 'def))

0 commit comments

Comments
 (0)