Issue Bug Closed

#106469TYPO3 RelativeCssPathFixer should ignore pure id-urls

Lars Peter Søndergaard 04/01/25, 08:40 updated 12/02/25, 14:21

Description

Currently, the RelativeCssPathFixer tries to fix all url(...) in CSS to a relative path.

This however does cause the issue, when using clip-path with a url pointing to an ID that is on the same page (e.g. svg clipPath element).

Example CSS:

.cropped-element {
  width: 100px;
  height: 100px;
  background: red;
  clip-path: url(#example-clip-path);
}

Example HTML:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1">
  <clipPath id="example-clip-path" clipPathUnits="objectBoundingBox">
    <path d="M 0.5,0 L 0.6545,0.3455 L 1,0.3819 L 0.7265,0.6180 L 0.8090,0.9511 L 0.5,0.8 L 0.1910,0.9511 L 0.2735,0.6180 L 0,0.3819 L 0.3455,0.3455 Z"></path>
  </clipPath>
</svg>

<div class="cropped-element"></div>

Expected output: The RelativeCsPathFixer leaves the purely id-based url in CSS untouched, as it’s not actually pointing to any file.

Actual Result: the url gets converted to a relative path, breaking the styling:
@clip-path: url(‘../../../_assets/c1dda3cd8b878b3d2d1341386e1ea699/Css/#example-clip-path’)@

I would argue that it should be safe to ignore all URLs starting with a hash (containing no path or other parts of a valid URL), as it doesn’t actually represent any file on the webserver (unless I’m overlooking something?).

It probably also affects older TYPO3 Versions, but I’ve only discovered it in TYPO3 13 now, due to rarely needing the clip-path feature.

I can of course easily avoid the issue by just not concatenating/compressing CSS files, but I’d like if this could be fixed.

Greetings
LPS

Reviews 3

History 37

  1. Lars Peter Søndergaard commented 04/01/25, 08:45

    Forgot to mention: This happens mostly with page.includeCSS and the like and setting the config:

    config {
      compressCss = 1
      concatenateCss = 1
    }

    f:asset.css may be unaffected by this issue.

  2. Gerrit Code Review pushed patch set 1 for main to change 88875 status New Under Review 04/01/25, 09:49

  3. Gerrit Code Review pushed patch set 2 for main to change 88875 04/01/25, 10:05

  4. Gerrit Code Review pushed patch set 1 for 13.4 to change 88896 04/02/25, 07:09

  5. Gerrit Code Review pushed patch set 1 for 12.4 to change 88897 04/02/25, 07:09

  6. Anonymous commented and changed status Under Review Resolved done 0 % 100 % 04/02/25, 07:25

    Applied in changeset commit:10287ded2dc0d92b09e50d78ca315ca9a9c7d5d7.

  7. Benni Mack changed status Resolved Closed 12/02/25, 14:21