There is 1 comment.
 
 
XWiki Platform / cid:jira-generated-image-avatar-ee0061d0-1db6-4c25-9ad6-b76449f03c3e XWIKI-19850 Open

The wiki is defaced when trying to use a Google Fonts 2022 import in the color theme - less compilation error

 
View issue   ยท   Add comment
 

1 comment

 
cid:jira-generated-image-avatar-bd77b09f-ef0a-4901-8cdb-f5f1a832b492 Charpentier Lucas on 22/May/25 11:07
 

This is an error from Less4J here. This `.less` suffix on filename is added by https://github.com/SomMeri/less4j/blob/bca5cb262c018f38ea8c58175df344c7d2345148/src/main/java/com/github/sommeri/less4j/core/compiler/stages/SingleImportSolver.java#L195-L200 .
It adds this suffix because it does not find it (no dot in the filename). The solver also checks beforehand if it's a raw CSS file (in which case, it does not change it in any way).
It detects CSS filenames with this boolean:

filename.endsWith(".css") || filename.endsWith("/css")

at https://github.com/SomMeri/less4j/blob/bca5cb262c018f38ea8c58175df344c7d2345148/src/main/java/com/github/sommeri/less4j/core/compiler/stages/SingleImportSolver.java#L209C1-L209C69

As expected, this detect the Roboto example from Paper as a CSS file, but does not detect the file that caused the problem.
____
We expect Less4J to understand this is a CSS file import. All of those functions are internal to Less4j, so here are some solutions:

  • Propose a fix for our use case directly on the Less4j repository. I'm not sure Less4j wants to fit all possible CSS file REST API addresses though, and a fix for us here might become a regression for someone else ^^'
  • Catch this pattern directly on XWiki side to add the proper import options for LESS to detect it as a CSS
  • Find and document an alternative syntax for this import (saying we don't support css2 API calls without the proper arguments)

I'll check solution 3 and see how easy it would be to inject it automatically for solution 2.