Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap/replace eval calls with function constructor calls to make the sloppy file strict-mode compliant #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions lib/sloppy.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
/* Domino uses sloppy-mode features (in particular, `with`) for a few
* minor things. This file encapsulates all the sloppiness; every
* other module should be strict. */
/* jshint strict: false */
/* jshint evil: true */
/* jshint -W085 */
module.exports = {
Window_run: function _run(code, file) {
"use strict";
if (file) code += '\n//@ sourceURL=' + file;
with(this) eval(code);
new Function("code", "with(this) eval(code)").call(this, code);
},
EventHandlerBuilder_build: function build() {
"use strict";
try {
with(this.document.defaultView || Object.create(null))
with(this.document)
with(this.form)
with(this.element)
return eval("(function(event){" + this.body + "})");
}
catch (err) {
return function() { throw err; };
return new Function("defaultView", "document", "form", "element", "event", "with(defaultView)with(document)with(form)with(element){"+this.body+"};").bind(this, this.document.defaultView || Object.create(null), this.document, this.form, this.element);
} catch (err) {
return function () { throw err; };
}
}
};