From: Bill Kelly Date: 2005-04-23T00:41:30+09:00 Subject: Re: [QUIZ] HighLine (#29) From: "James Edward Gray II" > > >> num = eval "0b#{ ask( 'Enter a binary number.', > >> String, :validate => /^[01_]+$/ ) }" > > > > Do not ever do that. > > > > irb(main):004:0> Integer("0b1011") > > => 11 > > irb(main):005:0> "1011".to_i(2) > > => 11 > > > > irb(main):006:0> "foo\nbar" =~ /^foo$/ > > => 0 > > I'm not exactly sure what you're trying to show here. Even 0 would be > a fine binary number. However, the point was that I have created a > safe eval() because ask() should not return anything that doesn't > validate. I think he meant along the lines of: irb --simple-prompt >> p "looks ok!" if "01010\nsystem('rm -rf /')" =~ /^[01_]+$/ "looks ok!" Regards, Bill