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
rotate and scale forms
- unresolved/invalid values retain existing error behavior
- ordinary composite converters that resolve to concrete values continue computing normally
- custom-property cycle coverage remains unchanged
Description
AngleSharp.Css 1.1.0stack-overflows when computing the style of an element with a valid CSS individual transform property such astranslate: 1px.The failure reproduces with AngleSharp alone: no Jint, JavaScript, custom properties, Scalar, or variable dependency cycles are involved.
Versions
1.8.01.1.0Minimal reproduction
Project references:
Actual behavior
The process exits with a stack overflow. The repeating native/.NET stack contains:
A complete standalone reproduction and failure log are available from the investigation that found this issue.
Root cause
The
translateproperty converter is shaped as anOrValueConvertercombiningnonewithAnyValueConverter.CssAnyValue.Computeavoids reparsing only whencontext.Converteris directly anAnyValueConverter.When the converter is the composite
OrValueConverter,Computereparses the unchanged text through that same composite converter. TheAnyValueConverterarm produces another unresolvedCssAnyValue, andCompute(context)is immediately invoked again with the same composite converter, causing unbounded converter re-entry.RotateConverterandScaleConverteruse 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 validtranslate,rotate, andscaledeclarations. Composite converters containing anAnyValueConvertermust not recursively reparse an unresolvedCssAnyValuewith the same converter indefinitely.Suggested coverage
translate: 1pxtranslate: nonerotateandscaleforms