diff --git a/content/io.js b/content/io.js index 0c50fa8f..201cd724 100644 --- a/content/io.js +++ b/content/io.js @@ -659,7 +659,7 @@ lookup: // handle pure javascript files specially if (/\.js$/.test(filename)) { - eval("with (liberator) {" + str + "}"); + liberator.eval(str); } else { @@ -671,7 +671,7 @@ lookup: { if (heredocEnd.test(line)) { - eval("with (liberator) {" + heredoc + "}"); + liberator.eval(heredoc); heredoc = ""; heredocEnd = null; } diff --git a/content/liberator.js b/content/liberator.js index 62537ec5..bc7a3e24 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -232,7 +232,7 @@ const liberator = (function () //{{{ { try { - var cmd = eval("with (liberator) {" + args + "}"); + var cmd = liberator.eval(args); liberator.execute(cmd); } catch (e) @@ -300,7 +300,7 @@ const liberator = (function () //{{{ { try { - eval("with (liberator) {" + args + "}"); + liberator.eval(args); } catch (e) { @@ -359,7 +359,7 @@ const liberator = (function () //{{{ else { while (i--) - eval("with (liberator) {" + args + "}"); + liberator.eval(args); } if (special) @@ -405,7 +405,7 @@ const liberator = (function () //{{{ if (args && args[0] == ":") liberator.execute(args); else - eval("with (liberator) {" + args + "}"); + liberator.eval(args); if (special) return; @@ -590,6 +590,12 @@ const liberator = (function () //{{{ return false; // so you can do: if (...) return liberator.beep(); }, + // with (liberator) means, liberator is the default namespace "inside" eval + eval: function (str) + { + return eval("with (liberator) {" + str + "}"); + }, + // Execute an ex command like str=":zoom 300" execute: function (str, modifiers) { diff --git a/content/ui.js b/content/ui.js index 053fc8b6..85297b0c 100644 --- a/content/ui.js +++ b/content/ui.js @@ -259,9 +259,7 @@ liberator.CommandLine = function () //{{{ try { - // TODO: move to liberator.eval()? - // with (liberator) means, liberator is the default namespace "inside" eval - arg = eval("with (liberator) {" + arg + "}"); + arg = liberator.eval(arg); } catch (e) {