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.
https://github.com/MoOx/pjax/blob/52fb3bf938941fc16f2731270a6c7391eb2bb61b/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.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
https://github.com/MoOx/pjax/blob/52fb3bf938941fc16f2731270a6c7391eb2bb61b/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.