Skip to content

Commit

Permalink
Fix content security policy issues per #22
Browse files Browse the repository at this point in the history
  • Loading branch information
101arrowz committed Dec 31, 2020
1 parent 3a7a6dd commit 5503f4d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.4.8
- Support strict Content Security Policy
- Remove `new Function`
## 0.4.7
- Fix data streaming bugs
## 0.4.5
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fflate",
"version": "0.4.7",
"version": "0.4.8",
"description": "High performance (de)compression in an 8kB package",
"main": "./lib/index.js",
"module": "./esm/index.mjs",
Expand Down
9 changes: 1 addition & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,13 +880,6 @@ const wcln = (fn: () => unknown[], fnStr: string, td: Record<string, unknown>) =
return [fnStr, td] as const;
}


// worker onmessage
const wom = (ev: MessageEvent<[Record<string, unknown>, string]>) => {
for (const k in ev.data[0]) self[k] = ev.data[0][k];
onmessage = new Function('return ' + ev.data[1])();
}

type CachedWorker = readonly [string, Record<string, unknown>];

const ch: CachedWorker[] = [];
Expand All @@ -908,7 +901,7 @@ const wrkr = <T, R>(fns: (() => unknown[])[], init: (ev: MessageEvent<T>) => voi
ch[id] = wcln(fns[m], fnStr, td);
}
const td = mrg({}, ch[id][1]);
return wk(ch[id][0] + ';onmessage=' + wom.toString(), id, [td, init.toString()], cbfs(td), cb);
return wk(ch[id][0] + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);
}

// base async inflate fn
Expand Down

0 comments on commit 5503f4d

Please sign in to comment.