Skip to main content
All docs
V26.1
  • CriteriaOperator.MaxParseDepth Property

    Specifies the maximum depth of a criteria tree that the criteria parser accepts.

    Namespace: DevExpress.Data.Filtering

    Assembly: DevExpress.Data.v26.1.dll

    NuGet Package: DevExpress.Data

    Declaration

    public static int MaxParseDepth { get; set; }

    Property Value

    Type Description
    Int32

    The maximum depth of a criteria tree. The default value is DefaultMaxParseDepth (1024). Zero or a negative value disables the limit.

    Remarks

    The MaxParseDepth property limits the depth of a criteria tree that the CriteriaOperator.Parse method and other parsing methods build from a string. Properties, constants, and parameters have depth 0. Each operator or function call adds one level. Parentheses and chains of the same logical operator (for instance, [A] = 1 And [B] = 2 And [C] = 3) do not add levels.

    If a criteria string exceeds the limit, the parser throws a CriteriaParserLimitException. The CriteriaParserLimitException.Kind property returns CriteriaParserLimitKind.Depth.

    The limit applies to the entire process. The parser reads the property value each time it parses a string. Set the property once at application startup, before the application parses criteria strings.

    The default value is designed to fit a standard thread stack. If your application accepts only short and simple filters, lower the limit.

    Warning

    Raise or disable this limit only after you verify that your application can safely process deeper criteria trees (for instance, verify the stack size of all threads that process criteria). A deeply nested criteria string from an untrusted source can cause a denial of service.

    The limit applies only to criteria strings. Criteria trees that you build in code are not subject to this limit.

    using DevExpress.Data.Filtering;
    
    // Call at application startup.
    CriteriaOperator.MaxParseDepth = 128;
    

    For additional information, refer to the following help topic: Criteria String Parsing and Untrusted Input.

    See Also