Skip to content

Parsing z-index values outside of int range throws an OverflowException #158

@ECrownofFire

Description

@ECrownofFire

For example, any z-index values greater than INT_MAX throws, such as this:

.foo {
    z-index: 99999999999999999;
}

Would also apply to values smaller than INT_MIN.

Stack trace
Unhandled exception. System.OverflowException: Value was either too large or too small for an Int32.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type)
   at System.Int32.Parse(String s, IFormatProvider provider)
   at ExCSS.NumberToken.get_IntegerValue()
   at ExCSS.ValueExtensions.ToInteger(IEnumerable`1 value)
   at ExCSS.StructValueConverter`1.Convert(IEnumerable`1 value)
   at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
   at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
   at ExCSS.OrValueConverter.Convert(IEnumerable`1 value)
   at ExCSS.Property.TrySetValue(TokenValue newTokenValue)
   at ExCSS.StylesheetComposer.CreateDeclarationWith(Func`2 createProperty, Token& token)
   at ExCSS.StylesheetComposer.FillDeclarations(StyleDeclaration style)
   at ExCSS.StylesheetComposer.CreateStyle(Token current)
   at ExCSS.StylesheetComposer.CreateRule(Token token)
   at ExCSS.StylesheetComposer.CreateRules(Stylesheet sheet)
   at ExCSS.StylesheetParser.Parse(TextSource source)
   at ExCSS.StylesheetParser.Parse(String content)
   at [redacted]

The standard doesn't actually limit z-index values to any particular range, though realistically speaking every browser clamps them to Int32.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions