Skip to content

CssLinkResourceTransformer does not use resolveUrlPath properly [SPR-12137] #16752

@spring-projects-issues

Description

@spring-projects-issues

Guillaume DROUET opened SPR-12137 and commented

Hi,

When the CssLinkResourceTransformer use the ResourceResolverChain#resolveUrlPath method to retrieve a resource referenced with url or @import, it gives as parameter the complete path. This is not what the ResourceUrlProvider does: before calling the chain, it removes the beginning of the path corresponding to the matching pattern.

Imagine you have the following configuration: registry.addResourceHandler("/css/**").addResourceLocations("classpath:/statics/css/")

If I resolve '/css/app.css' with ResourceUrlProvider, PathResourceResolver receives 'app.css' to resolve.

Now imagine in app.css a statement like this: @import "/css/app2.css";
In that case PathResourceResolver receives '/css/app2.css' from CssLinkResourceTransformer instead of 'app2.css'. The chain will return null and URL won't be transformed.

CssLinkResourceTransformer should rely on the same mechanism as ResourceUrlProvider.


Affects: 4.1 RC2

Referenced from: commits 125ae99

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions