Clojure

ns defmacro allows arbitrary execution of clojure.core fns

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.2, Release 1.3, Release 1.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    all
  • Patch:
    Code

Description

The form:

(ns foo (:print "I AM A ROBOT"))

will print "I AM A ROBOT"

This is because the defmacro takes the name of the first element of the reference, looks it up in the clojure.core namespace and invokes it on the rest of the args.

This is minor, but it does mean that an otherwise declarative form is not executing code.

Activity

Hide
Alan Malloy added a comment -

One apparent problem with this patch is that you throw an exception for :refer. You should add that, and make sure there aren't any others missing. Also, #{x y z} is better than (set [x y z]), and you should probably use pr-str rather than str, although I can't think of a case where it matters for the objects in question.

Show
Alan Malloy added a comment - One apparent problem with this patch is that you throw an exception for :refer. You should add that, and make sure there aren't any others missing. Also, #{x y z} is better than (set [x y z]), and you should probably use pr-str rather than str, although I can't think of a case where it matters for the objects in question.
Hide
Andy Fingerhut added a comment -

A more minor detail of patch formatting – please attach your patch in git format. See the instructions under the section heading "Development" on this web page: http://dev.clojure.org/display/design/JIRA+workflow

Show
Andy Fingerhut added a comment - A more minor detail of patch formatting – please attach your patch in git format. See the instructions under the section heading "Development" on this web page: http://dev.clojure.org/display/design/JIRA+workflow
Hide
Craig Brozefsky added a comment -

git format-patch version of the diff, with the edits suggested by other maintainers.

Show
Craig Brozefsky added a comment - git format-patch version of the diff, with the edits suggested by other maintainers.
Hide
Craig Brozefsky added a comment -

Alan: please note that :refer was not mentioned in the docstring for ns, or used in any of the unit tests for clojure.

Are you sure that it is an expected argument, or just an arrangement that happens to work under the current ns macro? The docstring for 'refer itself says to use :use in ns macros instead of calling refer.

I added "refer" to the set of accepted references all the same.

Show
Craig Brozefsky added a comment - Alan: please note that :refer was not mentioned in the docstring for ns, or used in any of the unit tests for clojure. Are you sure that it is an expected argument, or just an arrangement that happens to work under the current ns macro? The docstring for 'refer itself says to use :use in ns macros instead of calling refer. I added "refer" to the set of accepted references all the same.

People

Vote (3)
Watch (2)

Dates

  • Created:
    Updated: