Use an anonymous function to execute user scripts

This commit is contained in:
Arnaud Renevier 2008-07-19 17:52:03 +02:00 committed by Christian Dywan
parent fffb6253e1
commit 83285cb052

View file

@ -176,7 +176,7 @@ _js_script_from_file (JSContextRef js_context,
{
/* Wrap the script to prevent global variables */
gchar* wrapped_script = g_strdup_printf (
"var wrapped = function () { %s }; wrapped ();", script);
"(function () { %s })();", script);
if (gjs_script_eval (js_context, wrapped_script, exception))
result = TRUE;
g_free (wrapped_script);