Browse files

Fixed eval to give proper line number, exception handling on parse er…

…rors, escape code for eval of scripts
  • Loading branch information...
1 parent 818814a commit d8d93a8b340d84c71afcf6b7efed9d7870aaf606 @rscottm rscottm committed Apr 27, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 assets/demo-scripts/demo-irb-server.rb
View
6 assets/demo-scripts/demo-irb-server.rb
@@ -222,7 +222,7 @@ def eval_form(code="", rows=25)
<form action='/' method='post'>
<input type='submit' value='Eval' />
<input name='ui-thread' type='checkbox' /> Run on UI Thread
- <textarea id='code' name='code' rows='#{rows}' cols='100'>#{code}</textarea>
+ <textarea id='code' name='code' rows='#{rows}' cols='100'>#{WEBrick::HTMLUtils.escape(code)}</textarea>
</form><p/>
]
end
@@ -317,7 +317,7 @@ def do_POST(req, resp)
def evaluate(code, ui_thread)
p = Proc.new do
- java.lang.Thread.currentThread.setUncaughtExceptionHandler(@@exception_handler) if ui_thread
+ java.lang.Thread.currentThread.setUncaughtExceptionHandler(@@exception_handler)
if @@string_io.length > 0
s = @@string_io.string.clone
@@ -329,7 +329,7 @@ def evaluate(code, ui_thread)
puts code.length < 100 ? ">> #{code}\n" : ">> {code not echoed due to size}\n"
begin
- puts "=> #{$main_binding.eval(code).inspect}\n"
+ puts "=> #{eval(code, $main_binding, "eval", 1).inspect}\n"
rescue => e
puts e.message
puts e.backtrace.join("\n")

0 comments on commit d8d93a8

Please sign in to comment.