Repository navigation
Conversation
An anchor can store the same javascript: URL in href and xlink:href. The plugin spliced the anchor out for each attribute. The second splice ran at index -1 and replaced the parent's last child. Stop after the first unwrap so siblings stay in place. Fixes svg#2295
Splicing an anchor out while its parent is still being visited shifts the live child list, so the next sibling is never visited. An empty javascript: anchor left the following anchor in the document. Record each executable anchor once and unwrap it after the walk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
removeScriptscollapses an<a>whosehreforxlink:hrefisjavascript:, legacyvbscript:, or an executabledata:URL, and moves the anchor's children up to the parent. It did that splice during the anchor's exit, while the parent was still being walked.Two cases follow from that:
hrefandxlink:href. The plugin unwrapped once per attribute. After the first splice the anchor is no longer a child, so the secondindexOfis-1.splice(-1, 1, ...children)replaces the parent's last child.javascript:anchor left the following anchor, still pointing atjavascript:, in the document.Before this change the
<circle>is removed and the second anchor is left in place. A safehrefpaired with an executablexlink:hrefstill unwraps once. Nested executable anchors still unwrap from the inside out.Fixes #2295.
Verification
removeScripts.12fixture failed before the fix and passes after it. All 12removeScriptscases pass.pnpm test: 521 passed, 3 skipped, no type errors.pnpm lint,pnpm typecheck, andpnpm spellcheckpassed.The regression and browser-bundle jobs were not run locally.
removeScriptsis not part ofpreset-default; this applies when that plugin is enabled.