Updated the patch based on comments from rhickey.
New sample syntax is:
(binding [*read-eval* false] (read-string "#=(eval (def x 3))" ))
throws an Exception

Joshua


### Eclipse Workspace Patch 1.0
#P Clojure
Index: src/clj/clojure/core.clj
===================================================================
--- src/clj/clojure/core.clj    (revision 1332)
+++ src/clj/clojure/core.clj    (working copy)
@@ -4008,6 +4008,13 @@

   Defaults to true")

+(add-doc *read-eval*
+  "When set to logical false, the EvalReader (#=(...)) is disabled in
the
+  read/load in the thread-local binding.
+  Example: (binding [*read-eval* false] (read-string \"#=(eval (def x
3))\"))
+
+  Defaults to true")
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; helper
files ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (alter-meta! (find-ns 'clojure.core) assoc :doc "Fundamental library
of the Clojure language")
 (load "core_proxy")
Index: src/jvm/clojure/lang/RT.java
===================================================================
--- src/jvm/clojure/lang/RT.java        (revision 1332)
+++ src/jvm/clojure/lang/RT.java        (working copy)
@@ -178,6 +178,7 @@
                           new PrintWriter(new OutputStreamWriter(System.err,
UTF8), true));
 final static Keyword TAG_KEY = Keyword.intern(null, "tag");
 final static public Var AGENT = Var.intern(CLOJURE_NS, Symbol.create
("*agent*"), null);
+final static public Var READEVAL = Var.intern(CLOJURE_NS,
Symbol.create("*read-eval*"), T);
 final static public Var MACRO_META = Var.intern(CLOJURE_NS,
Symbol.create("*macro-meta*"), null);
 final static public Var MATH_CONTEXT = Var.intern(CLOJURE_NS,
Symbol.create("*math-context*"), null);
 static Keyword LINE_KEY = Keyword.intern(null, "line");
Index: src/jvm/clojure/lang/LispReader.java
===================================================================
--- src/jvm/clojure/lang/LispReader.java        (revision 1332)
+++ src/jvm/clojure/lang/LispReader.java        (working copy)
@@ -903,6 +903,11 @@

 public static class EvalReader extends AFn{
        public Object invoke(Object reader, Object eq) throws Exception{
+               if (!((Boolean)RT.READEVAL.deref()))
+           {
+                 throw new Exception("EvalReader not allowed when *read-eval* 
is
false.");
+           }
+
                PushbackReader r = (PushbackReader) reader;
                Object o = read(r, true, null, true);
                if(o instanceof Symbol)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to