Forum: Ruby Using ERb with $SAFE=4

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3ca7a660c046bf7956b39e65b3301f3f?d=identicon&s=25 Andy Morrow (Guest)
on 2007-04-03 00:48
(Received via mailing list)
I'm trying to use ERb to evaluate a template written by end users in
a Rails application I'm writing. Here's my code:

require 'erb'
template = "<%= 'Testing 1 2 3...' %>".taint #because it will be user
input in the final app
e = ERB.new(template, 4)
m = e.run
puts m

Here's what I get:
/usr/local/lib/ruby/1.8/erb.rb:739:in `eval': Insecure: can't modify
trusted binding (SecurityError)
         from /usr/local/lib/ruby/1.8/erb.rb:741:in `value'
         from /usr/local/lib/ruby/1.8/erb.rb:741:in `result'
         from /usr/local/lib/ruby/1.8/erb.rb:724:in `run'
         from tester.rb:4

What am I doing wrong?
Thanks,
Andy Morrow
This topic is locked and can not be replied to.