Issue Bug Closed

#109469Broken relative URLs in inline CSS after removal of `getStreamlinedFileName()`

Anton Danilov 04/02/26, 11:04 updated 04/21/26, 11:30

Description

When using PageRenderer::createCssTag() with the inline option enabled, relative URLs inside CSS files are incorrectly rewritten. PageRenderer::createInlineCssTagFromFile() calls fixRelativeUrlPaths() with the absolute file path as the base path. This causes fixRelativeUrlPaths() to treat the file as a directory when resolving relative URIs, resulting in incorrect absolute server paths being embedded in the CSS output.

Steps to Reproduce

1. Add a CSS file in an extension:

EXT:my_ext/Resources/Public/Css/style.css

2. Add a relative asset reference inside the CSS:

@font-face {
  font-family: 'MyFont';
  src: url('../Fonts/font.woff2') format('woff2');
}

3. Include the CSS via `PageRenderer` with inline enabled:

$pageRenderer->addCssFile(
    'EXT:my_ext/Resources/Public/Css/style.css',
    'stylesheet',
    'all',
    '',
    true // inline = true
);

4. Render the frontend output

Actual Behavior

The relative URL inside the CSS is rewritten to a filesystem path (starts with double slashes):

//var/www/html/vendor/myvendor/my-ext/Resources/Public/Fonts/font.woff2

This results in broken asset loading in the browser.

Expected Behavior

Relative URLs should be resolved based on the public URI of the CSS file and rewritten to a correct public path such as:

/_assets/<hash>/Fonts/font.woff2

Reviews 1

History 48

  1. Garvin Hicking changed category Is Regression 1 04/02/26, 16:37

  2. Garvin Hicking changed status New Accepted 04/06/26, 16:39

  3. Gerrit Code Review pushed patch set 1 for main to change 93626 status Accepted Under Review 04/11/26, 12:53

  4. Gerrit Code Review pushed patch set 2 for main to change 93626 04/11/26, 12:57

  5. Gerrit Code Review pushed patch set 3 for main to change 93626 04/11/26, 13:01

  6. Gerrit Code Review pushed patch set 4 for main to change 93626 04/11/26, 13:14

  7. Helmut Hummel commented and changed status Under Review Resolved done 0 % 100 % 04/12/26, 14:45

    Applied in changeset commit:14ae5c7e6d6d1fcdf6304b2dc64c6528c3b80d37.

  8. Benni Mack changed status Resolved Closed 04/21/26, 11:30