Skip to content

Commit

Permalink
Detect when document.currentScript is shadowed
Browse files Browse the repository at this point in the history
This does not fix any known security bug, just making sure if
someone adds <img name=currentScript> to the HTML then
we'll throw a helpful error instead of silently doing the wrong
thing.
  • Loading branch information
GarboMuffin committed Sep 25, 2024
1 parent 53a0c86 commit 2fadb28
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/packager/packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ cd "$(dirname "$0")"
let projectDecodeIndex = 0;
const decodeChunk = (size) => {
try {
if (document.currentScript.tagName.toUpperCase() !== 'SCRIPT') throw new Error('document.currentScript is not a script');
base85decode(document.currentScript.getAttribute("data"), projectDecodeBuffer, projectDecodeIndex);
document.currentScript.remove();
projectDecodeIndex += size;
Expand Down

0 comments on commit 2fadb28

Please sign in to comment.