Check for presence of script node before post eval cleanup #185
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
52fb3bf938/lib/eval-script.js (L37)Sometimes a script tag can contain code that, on execution, cleans up after itself by removing the original script node. For example, an obfuscation snippet that uses
document.currentScript.parentNode.removeChild(document.currentScript)to remove the script node and replace it with the decoded content.In such a case, Pjax results in a
DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.while attempting to cleanup. It would be great if there was a condition that checked for the presence of the script node post eval before attempting to remove it.Suggestion: a
parent.contains(script)check beforeparent.removeChild(script)might do the trick.