-
Notifications
You must be signed in to change notification settings - Fork 5k
css: bound raw-token expansion when compiling nesting for older targets #32453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
243fd46
683ab5e
5fdb6b4
ce6f00d
906877e
29405e1
a82c7cd
956d792
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -389,19 +389,36 @@ | |
| &self, | ||
| context: &mut MinifyContext<'_, '_>, | ||
| ) -> Result<(), MinifyErr> { | ||
| if context.selector_expansion_multiplier > 1 { | ||
|
Check warning on line 392 in src/css/rules/style.rs
|
||
|
robobun marked this conversation as resolved.
|
||
| context.selector_expansion_total = context.selector_expansion_total.saturating_add( | ||
| context | ||
| .selector_expansion_multiplier | ||
| .saturating_mul(self.selectors.v.len().max(1)), | ||
| ); | ||
| let copies = context | ||
| .selector_expansion_multiplier | ||
| .saturating_mul(self.selectors.v.len().max(1)); | ||
| context.selector_expansion_total = | ||
| context.selector_expansion_total.saturating_add(copies); | ||
| if context.selector_expansion_total > super::MAX_SELECTOR_EXPANSION { | ||
| context.err = Some(crate::error::MinifyError { | ||
| kind: crate::error::MinifyErrorKind::selector_expansion_limit_exceeded, | ||
| loc: self.loc, | ||
| }); | ||
| return Err(MinifyErr::minify_err); | ||
| } | ||
| // Same expansion multiplies this rule's unparsed/custom property | ||
| // token lists. A large raw value under the selector cap still | ||
| // deep-clones into gigabytes of `TokenOrValue`, so budget the | ||
| // token payload separately. | ||
| let weight = self.declarations.token_weight(); | ||
| if weight > 0 { | ||
| context.token_expansion_total = context | ||
| .token_expansion_total | ||
|
Check warning on line 412 in src/css/rules/style.rs
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Beyond Extended reasoning...What this adds to the comment aboveThe 🔴 comment above establishes that Carrier 1:
|
||
| .saturating_add((copies as usize).saturating_mul(weight)); | ||
| if context.token_expansion_total > super::MAX_TOKEN_EXPANSION { | ||
| context.err = Some(crate::error::MinifyError { | ||
| kind: crate::error::MinifyErrorKind::token_expansion_limit_exceeded, | ||
| loc: self.loc, | ||
| }); | ||
| return Err(MinifyErr::minify_err); | ||
| } | ||
| } | ||
|
robobun marked this conversation as resolved.
Outdated
|
||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.