Repository navigation
🐛 fix(dom): skip template and foreign base/meta tags - #2231
Merged
gaborbernat merged 2 commits intoNov 16, 2026
Merged
Conversation
Base URL, meta refresh and link extraction walked every node, so a <base> or <meta http-equiv=refresh> inside <template>, or an SVG or MathML element named base or meta, could hide the one a browser acts on or be reported as the redirect. Crawlers and link checkers that resolve links against the base then used the wrong URL. The walks now skip template contents, and the base and refresh lookups accept only HTML elements. Links inside a template are still reported; only the refresh redirect changes. PR tox-dev#2175 made this change first, but the squash merge of tox-dev#2185 (612eda8) dropped it from main, so release 1.15.11 shipped without it. This commit re-applies it on the current main. Fixes tox-dev#1685
Merging this PR will not alter performance
Comparing Footnotes
|
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.
Document.base_url(),Document.meta_refresh()andNode.links()find the document's<base href>and its refresh<meta>by walking every node, template contents included (base walk, refresh walk, link refresh check). A crawler or link checker that resolves links against the base could therefore pick a<base>that a browser never reads, or follow a refresh tag that a browser ignores. Once this merges, these calls return the base and redirect that a browser follows. Fixes #1685.The HTML standard keeps a
<template>'s children in a separate inert document (template element), so the walks now step over template contents. The base and refresh lookups also accept only HTML elements, because abaseormetain the SVG or MathML namespace is not the document's base element. Link extraction applies the same rule to refresh tags and still reports<a href>and other URLs found inside templates, as before.Callers of the base lookup, including
extract_links()andstructured_data(), now get the next real base element or the fallback when the only<base href>sits in a template or in SVG or MathML. A refresh tag in those places no longer redirects frommeta_refresh(),links(),rewrite_links()orresolve_links().The change was first merged as #2175 (
4e1f30910). The squash merge of #2185 (612eda868) then dropped it frommain, and release 1.15.11 shipped without it. This PR re-applies the change on the currentmainand leaves the XSD changes from #2185 as they are.