aryankalantri opened a new pull request, #1977:
URL: https://github.com/apache/wicket/pull/1977

   Fixes #1952.
   
   Inside `<wicket:link>` (and for relative paths in general), Wicket rewrites 
the URLs in `href`, `src` and `background` attributes so they resolve relative 
to the page's package. The `srcset` attribute of `<img>` and `<source>` was not 
rewritten, so responsive images in static markup broke.
   
   ## What changed
   
   `RelativePathPrefixHandler` now rewrites `srcset` the same way it rewrites 
`src`:
   
   - Each comma-separated `url descriptor` candidate is rewritten on its own 
with `UrlUtils.rewriteToContextRelative`, keeping its descriptor (`480w`, `2x`, 
...).
   - Absolute URLs, absolute paths and fragments are left alone, using the same 
guards as the single-URL attributes. A `srcset` holding only absolute URLs does 
not get the behavior attached.
   - The shared `isRelativeUrl` check is now used for the existing attributes 
too (no behavior change there).
   
   Scope notes (decisions from the issue):
   
   - `srcset` is only handled in `RelativePathPrefixHandler` (plain markup). 
Inside `<wicket:link>`, `AutoLinkResolver` resolves one attribute to one 
package resource, so a multi-URL `srcset` cannot be auto-linked the same way; 
that stays unhandled and is out of scope here.
   - A `data:` URI in `srcset` is 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 in `RelativePathPrefixHandlerTest` with `Page_4` 
fixtures: two relative candidates on `<img>`, a mixed 
relative/absolute-path/absolute-URL `srcset`, a `<source srcset>` inside 
`<picture>` plus an `<img src>` fallback, and a `2x` descriptor.
   
   - `RelativePathPrefixHandlerTest`: 4/4 pass with the fix. The new test fails 
on unmodified `master` (expected output not produced), so it detects the bug.
   - Full `org.apache.wicket.markup.parser` package: 51/51 pass.
   
   Tests were run locally with a manual `javac` build (JDK 21) because Maven 
cannot download dependencies in this environment: Java TLS through the egress 
proxy is reset, while `curl` works. The full `mvn verify` run is left to CI as 
arbiter.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to