Re: Avoiding an Infinite Loop in Arbitrary eval(user_code)
- From: Thomas 'PointedEars' Lahn <PointedEars@xxxxxx>
- Date: Wed, 23 Apr 2008 19:07:26 +0200
Bill Mill wrote:
I want to have a user able to eval code in a text box. However, if he
accidentally types "while(1) { i=0; }" and hits "run", I also want him
to be able to hit a stop button such that his browser does not go into
an infinite, soul-crushing, interface-locking loop. The stop button
would not need to be instantly responsive, but of course the more
responsive the better.
Short of writing a javascript-in-javascript interpreter, is there any
way to do so?
No. ECMAScript implementations so far are single-threaded, and there is yet
an algorithm to be written for a universal solution of the Halting Problem.
http://en.wikipedia.org/wiki/Halting_problem
You will have to rely on the user's user agent to recognize a not-responding
script, and provide the user with such a dialog window, as Gecko-based UAs
(e.g. Mozilla Firefox) do.
Does Caja make this sort of thing possible?
I don't think so:
http://code.google.com/p/google-caja/wiki/AttackVectors
Please be more verbose next time.
Will I need to restrict myself to Gears+threads to do this?
Never heard of those.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
.
- Follow-Ups:
- Re: Avoiding an Infinite Loop in Arbitrary eval(user_code)
- From: Bill Mill
- Re: Avoiding an Infinite Loop in Arbitrary eval(user_code)
- References:
- Avoiding an Infinite Loop in Arbitrary eval(user_code)
- From: Bill Mill
- Avoiding an Infinite Loop in Arbitrary eval(user_code)
- Prev by Date: Re: Empty <span> + onlick
- Next by Date: Re: onKeyUp event not firing...or just bad code?
- Previous by thread: Re: Avoiding an Infinite Loop in Arbitrary eval(user_code)
- Next by thread: Re: Avoiding an Infinite Loop in Arbitrary eval(user_code)
- Index(es):
Loading