theforeman / safemode

A library for safe evaluation of Ruby code based on ParseTree/RubyParser and Ruby2Ruby. Provides Rails ActionView template handlers for ERB and Haml.
http://www.artweb-design.de
MIT License
68 stars 20 forks source link

Array arguments incorrectly parsed #7

Open seanlinsley opened 11 years ago

seanlinsley commented 11 years ago

This code prevents single-element arrays from being passed as an argument.

if args_exp && args_exp.first == :array # FIX
  processed = "#{process(args_exp)[1..-2]}"
else
  processed = process args_exp
end

A simple example:

[3] | [4]

Changing it to a one-liner works just fine, and the tests pass :)

processed = process args_exp

Does anyone know what that conditional was supposed to fix? I can't seem to find an example.

kronn commented 11 years ago

Hard to say, as it's hidden in the initial commit, which is 5 years in the past.

@svenfuchs, can you remember the reason for this?