]> spindle.queued.net Git - midori/commitdiff
Wrap userscripts in an anonymous function.
authorChristian Dywan <christian@twotoasts.de>
Sat, 3 May 2008 23:34:39 +0000 (01:34 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sat, 3 May 2008 23:34:39 +0000 (01:34 +0200)
src/midori-addons.c

index c5cbe6e1568be93e01683e2066979580f4d93e7e..552f7972f2d608b29a72f9ed3c7da8d5cac2104f 100644 (file)
@@ -521,8 +521,11 @@ _js_document_load_script_file (JSContextRef js_context,
     GError* error = NULL;
     if (g_file_get_contents (filename, &script, NULL, &error))
     {
-        if (_js_eval (js_context, script, exception))
+        gchar* wrapped_script = g_strdup_printf (
+            "var wrapped = function () { %s }; wrapped ();", script);
+        if (_js_eval (js_context, wrapped_script, exception))
             result = TRUE;
+        g_free (wrapped_script);
         g_free (script);
     }
     else