-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(es/minifier): Fix detection of direct eval
#6215
Changes from all commits
e1b47a3
75f8dbb
72e0fba
428af50
4bd3e16
c08eef9
0e888cf
9b7a78f
00a1297
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
var c = a; | ||
c(); | ||
var d = a.b; | ||
d(); | ||
var e = eval; | ||
e(); | ||
var v = a; | ||
v(); | ||
var r = a.b; | ||
r(); | ||
var b = eval; | ||
b(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
(function(foo) { | ||
(0, foo)(); | ||
(0, foo.bar)(); | ||
(function(o) { | ||
(0, o)(); | ||
(0, o.bar)(); | ||
(0, eval)("console.log(foo);"); | ||
})(); | ||
(function(foo) { | ||
(function(o) { | ||
var eval = console; | ||
(0, foo)(); | ||
(0, foo.bar)(); | ||
(0, o)(); | ||
(0, o.bar)(); | ||
(0, eval)("console.log(foo);"); | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function f1(a, eval, c, d, e) { | ||
return a("c") + eval; | ||
function f1(n, eval, c, r, t) { | ||
return n("c") + eval; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added code to explicitly prevent it because |
||
} | ||
function f2(a, b, c, d, e) { | ||
return a + eval("c"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,17 @@ impl Visit for EvalFinder { | |
|
||
fn visit_export_namespace_specifier(&mut self, _: &ExportNamespaceSpecifier) {} | ||
|
||
fn visit_ident(&mut self, i: &Ident) { | ||
if i.sym == js_word!("eval") { | ||
self.found = true; | ||
fn visit_callee(&mut self, c: &Callee) { | ||
c.visit_children_with(self); | ||
|
||
if let Callee::Expr(e) = c { | ||
if let Expr::Ident(Ident { | ||
sym: js_word!("eval"), | ||
Comment on lines
+37
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how you represent optional chains, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh it was |
||
.. | ||
}) = &**e | ||
{ | ||
self.found = true | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an indirect eval, so it cannot use
c
norb