mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2950] [Issue]: Nested conditional styles in a card (e.g. @media inside @supports) lose their outer condition #1528
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1528
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2950
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
When a character card's CSS nests two at-rules — for example
@mediawrapping@supports— the card-CSS scoper drops the outer at-rule and keeps only the inner rules. The inner rules are still safely scoped (no security problem), but they now apply unconditionally instead of only under the intended condition. So a style the card author meant for "narrow screens only" (or "only if the browser supports grid") silently applies everywhere. It's a quiet correctness bug that's hard to debug because the CSS looks fine in the card.How to reproduce (try it yourself)
<style>, put:#marinara-card-css<style>.You'll see (verified by running the actual
scopeChatCssagainst this input):The
@media (max-width: 600px)wrapper is gone, so.bubbleis hidden at every width, not just below 600px. The reverse nesting (@supports { @media { … } }) drops the@supportsthe same way (also verified).Expected: the full nesting is preserved so the rule only applies when both conditions match.
Where it is
packages/client/src/lib/card-css.ts—scopeChatCss, the rule-splitter regexruleReat line 525:/([^{}]+)\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/gunderstands only one level of brace nesting in a rule body, and the recursive at-rule branch at lines 545-549 only fires when the outer block is the one matched — which never happens for double-nested at-rules. So the regex matches the inner at-rule first and the outer prelude is left behind as inter-rule text and dropped.
What's happening
ruleRecan't match an at-rule whose body itself contains a nested{…}{…}ruleset, so for@media{@supports{…}}it skips the@mediaprelude and matches@supports{…}directly, discarding the@mediacondition.Suggested fix
The file already has a string/comment/brace-aware scanner,
findCssBlockEnd(lines 18-64). Use it (or a small generalization) to split rules by real brace depth instead of the regex, so at-rule preludes are captured and recursed into at any nesting depth. (Worth also checking the separate inline-message<style>scoper inChatMessage.tsxfor the same one-level limitation.)AI-investigated against v2.0.6; reproduced by running the real
scopeChatCss. Please confirm before fixing.@SpicyMarinara commented on GitHub (Jun 28, 2026):
Fixed on staging: card CSS scoping now uses a brace-aware rule splitter so nested conditional at-rules preserve their outer conditions.