Skip to content

Commit

Permalink
Remove direct eval in pyodide.asm.js and minify setupEmscripten.
Browse files Browse the repository at this point in the history
This replaces direct eval in pyodide.asm.js with indirect eval, see
comment in the commit.
  • Loading branch information
danlapid committed Oct 16, 2024
1 parent e96758b commit 6e8be63
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/pyodide/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ REPLACEMENTS = [
"crypto.getRandomValues(",
"getRandomValues(Module, ",
],
[
# Direct eval disallowed in esbuild, see:
# https://esbuild.github.io/content-types/#direct-eval
"eval(func)",
"(() => {throw new Error('Internal Emscripten code tried to eval, this should not happen, please file a bug report with your requirements.txt file\\'s contents')})()",
],
[
"eval(data)",
"(() => {throw new Error('Internal Emscripten code tried to eval, this should not happen, please file a bug report with your requirements.txt file\\'s contents')})()",
],
[
"eval(UTF8ToString(ptr))",
"(() => {throw new Error('Internal Emscripten code tried to eval, this should not happen, please file a bug report with your requirements.txt file\\'s contents')})()",
],
]

PYODIDE_BUCKET_MODULE = json.encode({
Expand Down

0 comments on commit 6e8be63

Please sign in to comment.