Repository navigation
Description
Description
AngleSharp.Css 1.1.0 stack-overflows when computing the style of an element with a valid CSS individual transform property such as translate: 1px.
The failure reproduces with AngleSharp alone: no Jint, JavaScript, custom properties, Scalar, or variable dependency cycles are involved.
Versions
- AngleSharp:
1.8.0 - AngleSharp.Css:
1.1.0 - .NET 10.0
- Also relevant to the current source implementation unless already changed
Minimal reproduction
using AngleSharp;
using AngleSharp.Css.Dom;
var context = BrowsingContext.New(Configuration.Default.WithCss());
var document = await context.OpenAsync(request => request.Content(
"<html><body><div style='translate: 1px'></div></body></html>"));
var element = document.QuerySelector("div")!;
var style = element.ComputeCurrentStyle();
Console.WriteLine(style.GetPropertyValue("translate"));Project references:
<PackageReference Include="AngleSharp" Version="1.8.0" />
<PackageReference Include="AngleSharp.Css" Version="1.1.0" />Actual behavior
The process exits with a stack overflow. The repeating native/.NET stack contains:
CssAnyValue.Compute
IdentifierValueConverter.Convert
OrValueConverter.Convert
CssAnyValue.Compute
...
A complete standalone reproduction and failure log are available from the investigation that found this issue.
Root cause
The translate property converter is shaped as an OrValueConverter combining none with AnyValueConverter. CssAnyValue.Compute avoids reparsing only when context.Converter is directly an AnyValueConverter.
When the converter is the composite OrValueConverter, Compute reparses the unchanged text through that same composite converter. The AnyValueConverter arm produces another unresolved CssAnyValue, and Compute(context) is immediately invoked again with the same composite converter, causing unbounded converter re-entry.
RotateConverter and ScaleConverter use the same converter shape and may be affected as well.
This is distinct from custom-property dependency-cycle handling such as #242. The reparsing branch predates that fix.
Expected behavior
ComputeCurrentStyle() should terminate and return the computed value for valid translate, rotate, and scale declarations. Composite converters containing an AnyValueConverter must not recursively reparse an unresolved CssAnyValue with the same converter indefinitely.
Suggested coverage
translate: 1px- valid two- and three-component translate forms
translate: none- corresponding valid
rotateandscaleforms - unresolved/invalid values retain existing error behavior
- ordinary composite converters that resolve to concrete values continue computing normally
- custom-property cycle coverage remains unchanged
Activity
sebastienros commentedon Sep 7, 2026
Additional native verification confirms this is not a 1.1.0 or custom-property-cycle regression: the same standalone program also stack-overflows with AngleSharp.Css 1.0.2 (AngleSharp 1.8.0).
translate: 1px,translate: 0 -50%,rotate: 45deg, andscale: 1are all confirmed failures;translate: none,rotate: none,scale: none, and the existing custom-property cycle fallback control complete normally. Rotate and scale are therefore confirmed affected, not merely suspected, and downgrading to 1.0.2 is not a workaround.sebastienros commentedon Sep 7, 2026
Reproduction correction and history: add
using AngleSharp.Dom;soQuerySelectorresolves. The bug is present in published 1.1.0 and currentdevel/main; converter re-entry dates to commit8295892(January 2024), while individual transform converters exposed it ine050f3c(July 2026), before #242. PR #242 changed full-consumption/IsResolvedbehavior but did not introduce this recursion.Move to AngleSharp.Css 1.1.1-beta.308, the preview with the converter…
Fix unresolved-any re-entry during style computation