Using ERb with $SAFE=4

A

Andy Morrow

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top