diff options
author | nfebe <fenn25.fn@gmail.com> | 2025-07-07 20:37:18 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2025-07-11 19:49:14 +0000 |
commit | 5acf36f17dd2a052c81db086a302d04cde5f2956 (patch) | |
tree | 121e22f3bb8d7d67c03b096f90fdeabfef551132 | |
parent | 6fe42f9423f1169507b0e947a7b1321fa9dcf88d (diff) | |
download | nextcloud-server-backport/53857/stable31.tar.gz nextcloud-server-backport/53857/stable31.zip |
fix(theming): Correctly generate CSS for font themesbackport/53857/stable31
Fixes a regression from dropping the SCSS compiler that broke
font themes like OpenDyslexic. The old code relied on the SCSS
compiler to automatically correct the order of the CSS rules,
ensuring the @font-face declaration was always valid.
The server now correctly generates the `@font-face` rule at
the top level of the stylesheet, fixing the previously invalid nested CSS.
Introduced in : f1448fcf0777db7d4254cb0a3ef94d63be9f7a24
Signed-off-by: nfebe <fenn25.fn@gmail.com>
-rw-r--r-- | apps/theming/lib/Controller/ThemingController.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index 880c0e08ea5..7f500d6b92e 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -401,7 +401,17 @@ class ThemingController extends Controller { $css = ":root { $variables } " . $customCss; } else { // If not set, we'll rely on the body class - $css = "[data-theme-$themeId] { $variables $customCss }"; + // We need to separate @-rules from normal selectors, as they can't be nested + // This is a replacement for the SCSS compiler that did this automatically before f1448fcf0777db7d4254cb0a3ef94d63be9f7a24 + // We need a better way to handle this, but for now we just remove comments and split the at-rules + // from the rest of the CSS. + $customCssWithoutComments = preg_replace('!/\*.*?\*/!s', '', $customCss); + $customCssWithoutComments = preg_replace('!//.*!', '', $customCssWithoutComments); + preg_match_all('/(@[^{]+{(?:[^{}]*|(?R))*})/', $customCssWithoutComments, $atRules); + $atRulesCss = implode('', $atRules[0]); + $scopedCss = preg_replace('/(@[^{]+{(?:[^{}]*|(?R))*})/', '', $customCssWithoutComments); + + $css = "$atRulesCss [data-theme-$themeId] { $variables $scopedCss }"; } try { |