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. Gerrit Code Review pushed patch set 1 for main to change 93626 status Accepted Under Review <span data-processor="relativetime" data-value="2026-04-11T12:53:23+00:00" > 04/11/26, 12:53 </span>

  2. Helmut Hummel commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-04-12T14:45:09+00:00" > 04/12/26, 14:45 </span>

    Applied in changeset commit:14ae5c7e6d6d1fcdf6304b2dc64c6528c3b80d37.