Skip to content

Commit cd76972

Browse files
committed
Revert "feat(WebAssemblyParser): error when restriction are hit"
This reverts commit 0ef8c12.
1 parent 6f5560c commit cd76972

1 file changed

Lines changed: 0 additions & 47 deletions

File tree

‎lib/WebAssemblyParser.js‎

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,12 @@ const { decode } = require("@webassemblyjs/wasm-parser");
99

1010
const { Tapable } = require("tapable");
1111
const WebAssemblyImportDependency = require("./dependencies/WebAssemblyImportDependency");
12-
const { readFileSync } = require("fs");
13-
const { join } = require("path");
1412

1513
const decoderOpts = {
1614
ignoreCodeSection: true,
1715
ignoreDataSection: true
1816
};
1917

20-
// FIXME(sven): probably a better way of doing this?
21-
function getSource(context, request) {
22-
const path = require.resolve(join(context, request));
23-
return readFileSync(path, "utf8");
24-
}
25-
26-
// FIXME(sven): probably a better way of doing this?
27-
function ensureExported(source, request) {
28-
const hasExport = source.indexOf("export ") !== -1;
29-
30-
if (hasExport === false) {
31-
const error = new Error(
32-
request + " must export the Memory or Table object."
33-
);
34-
35-
error.stack = "";
36-
37-
throw error;
38-
}
39-
}
40-
41-
// FIXME(sven): probably a better way of doing this?
42-
function ensureIdentNotAccessed(source, request, ident) {
43-
const occurence = source.match(new RegExp(ident, "g")).length;
44-
45-
if (occurence > 1) {
46-
const error = new Error(
47-
request + " is not allowed to access the Memory or Table object (yet)."
48-
);
49-
50-
error.stack = "";
51-
52-
throw error;
53-
}
54-
}
55-
5618
class WebAssemblyParser extends Tapable {
5719
constructor(options) {
5820
super();
@@ -82,15 +44,6 @@ class WebAssemblyParser extends Tapable {
8244
);
8345

8446
state.module.addDependency(dep);
85-
86-
// To avoid unexpected behaviors we check that the Memory or Table
87-
// has been exported and is not accessed by the user.
88-
if (node.descr.type === "Memory" || node.descr.type === "Table") {
89-
const content = getSource(state.module.context, node.module);
90-
91-
ensureExported(content, node.module);
92-
ensureIdentNotAccessed(content, node.module, node.name);
93-
}
9447
}
9548
});
9649

0 commit comments

Comments
 (0)