Repository navigation
Rewrite relative URLs in srcset attributes (#1952) - #1977
Open
aryankalantri wants to merge 5 commits into
Open
aryankalantri wants to merge 5 commits into
aryankalantri wants to merge 5 commits into
Conversation
GitHub issue apache#1952
GitHub issue apache#1952
GitHub issue apache#1952
GitHub issue apache#1952
GitHub issue apache#1952
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.
Fixes #1952.
Inside
<wicket:link>(and for relative paths in general), Wicket rewrites the URLs inhref,srcandbackgroundattributes so they resolve relative to the page's package. Thesrcsetattribute of<img>and<source>was not rewritten, so responsive images in static markup broke.What changed
RelativePathPrefixHandlernow rewritessrcsetthe same way it rewritessrc:url descriptorcandidate is rewritten on its own withUrlUtils.rewriteToContextRelative, keeping its descriptor (480w,2x, ...).srcsetholding only absolute URLs does not get the behavior attached.isRelativeUrlcheck is now used for the existing attributes too (no behavior change there).Scope notes (decisions from the issue):
srcsetis only handled inRelativePathPrefixHandler(plain markup). Inside<wicket:link>,AutoLinkResolverresolves one attribute to one package resource, so a multi-URLsrcsetcannot be auto-linked the same way; that stays unhandled and is out of scope here.data:URI insrcsetis out of scope: it contains a comma by construction, so the comma-split parsing cannot tell its payload apart from a second candidate.How tested
New
srcset()test inRelativePathPrefixHandlerTestwithPage_4fixtures: two relative candidates on<img>, a mixed relative/absolute-path/absolute-URLsrcset, a<source srcset>inside<picture>plus an<img src>fallback, and a2xdescriptor.RelativePathPrefixHandlerTest: 4/4 pass with the fix. The new test fails on unmodifiedmaster(expected output not produced), so it detects the bug.org.apache.wicket.markup.parserpackage: 51/51 pass.Tests were run locally with a manual
javacbuild (JDK 21) because Maven cannot download dependencies in this environment: Java TLS through the egress proxy is reset, whilecurlworks. The fullmvn verifyrun is left to CI as arbiter.