From: nascheme at m67.enme.ucalgary.ca (Neil Schemenauer)
Date: 14 Apr 1999 23:00:22 GMT
Subject: reval builtin
References: <19990331160323.21601.00000471@ng-fi1.aol.com> <7du3ab$3ag@chronicle.concentric.net> <jtaewsfmlj.fsf@wazor.biostat.wisc.edu> <xcxP2.1302$rd2.27684@news14.ispnews.com> <371219E9.9EA91839@home.com>
Message-ID: <7f36m6$koq@ds2.acs.ucalgary.ca>
X-UID: 492                                                  

On Mon, 12 Apr 1999 15:59:05 GMT, Jim Meier <fatjim at home.com> wrote:
>This introduces some major security problems, and is a little difficult
>to edit, but there is very little parsing needed to make it usable.  Does
>anyone know of a way to limit the damage a user can do to such a file?

It would be nice to have an "reval" builtin that would only evaluate
literals.  That would make building things like config files safe and
easy.  I have two ideas on how to accomplish this:

	1. Create a new start symbol "reval_input" in the Grammar/Grammar
	and add a "builtin_reval" function in Python/bltinmodule.c.  Sound
	easy?  Well, the connection between these two changes is long and
	twisted.

	2. Use something like lex and yacc to create an extension module
	that does the Right Thing(TM).  I think the problem with this
	approach is making it conform to the real Python grammar.  If I
	get time I will try it.

Perhaps some guru can explain an easy way to accomplish this and same me
some time.


    Neil




