From: Peter Triller
Date: 2006-04-07T05:43:14+09:00
Subject: Re: Embedding ruby
Michael Greenly wrote:
>check out http://www.rubycentral.com/book/taint.html
>
>
>
Thanks a lot. This seems to be what I need.
But ..
I did a few tests and the results where not exactly what I expected.
I want to have the code I get in a parsed form and not in a string form,
so I need to 'compile' it into functions.
something along the lines:
eval "$SAFE=4;
class Foo
def bar()
" << userCode << "
end
end
";
this wasnt working. so I read around in the docu:
"Can't define, redefine, remove, or undef a method in a nontainted class
or module."
so I figured this would work:
userCode ="a = 3 + 4;";
class Foo
end
Foo.taint;
eval "$SAFE=4;
class Foo
def bar()
" << userCode << "
end
end
";
but it wasn't either.
I got a:
test.rb:11: (eval):2: extending class prohibited (SecurityError)
So is the docu wrong, or am I just reading it wrong ?
Thanks
Peter