|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
|
* Copyright 2002-2023 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -30,6 +30,12 @@ import org.springframework.lang.Nullable;
@@ -30,6 +30,12 @@ import org.springframework.lang.Nullable;
|
|
|
|
|
*/ |
|
|
|
|
public class SpelParserConfiguration { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Default maximum length permitted for a SpEL expression. |
|
|
|
|
* @since 5.2.24 |
|
|
|
|
*/ |
|
|
|
|
private static final int DEFAULT_MAX_EXPRESSION_LENGTH = 10_000; |
|
|
|
|
|
|
|
|
|
/** System property to configure the default compiler mode for SpEL expression parsers: {@value}. */ |
|
|
|
|
public static final String SPRING_EXPRESSION_COMPILER_MODE_PROPERTY_NAME = "spring.expression.compiler.mode"; |
|
|
|
|
|
|
|
|
|
@ -54,6 +60,8 @@ public class SpelParserConfiguration {
@@ -54,6 +60,8 @@ public class SpelParserConfiguration {
|
|
|
|
|
|
|
|
|
|
private final int maximumAutoGrowSize; |
|
|
|
|
|
|
|
|
|
private final int maximumExpressionLength; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new {@code SpelParserConfiguration} instance with default settings. |
|
|
|
|
@ -102,11 +110,30 @@ public class SpelParserConfiguration {
@@ -102,11 +110,30 @@ public class SpelParserConfiguration {
|
|
|
|
|
public SpelParserConfiguration(@Nullable SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, |
|
|
|
|
boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize) { |
|
|
|
|
|
|
|
|
|
this(compilerMode, compilerClassLoader, autoGrowNullReferences, autoGrowCollections, |
|
|
|
|
maximumAutoGrowSize, DEFAULT_MAX_EXPRESSION_LENGTH); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new {@code SpelParserConfiguration} instance. |
|
|
|
|
* @param compilerMode the compiler mode that parsers using this configuration object should use |
|
|
|
|
* @param compilerClassLoader the ClassLoader to use as the basis for expression compilation |
|
|
|
|
* @param autoGrowNullReferences if null references should automatically grow |
|
|
|
|
* @param autoGrowCollections if collections should automatically grow |
|
|
|
|
* @param maximumAutoGrowSize the maximum size that a collection can auto grow |
|
|
|
|
* @param maximumExpressionLength the maximum length of a SpEL expression; |
|
|
|
|
* must be a positive number |
|
|
|
|
* @since 5.2.25 |
|
|
|
|
*/ |
|
|
|
|
public SpelParserConfiguration(@Nullable SpelCompilerMode compilerMode, @Nullable ClassLoader compilerClassLoader, |
|
|
|
|
boolean autoGrowNullReferences, boolean autoGrowCollections, int maximumAutoGrowSize, int maximumExpressionLength) { |
|
|
|
|
|
|
|
|
|
this.compilerMode = (compilerMode != null ? compilerMode : defaultCompilerMode); |
|
|
|
|
this.compilerClassLoader = compilerClassLoader; |
|
|
|
|
this.autoGrowNullReferences = autoGrowNullReferences; |
|
|
|
|
this.autoGrowCollections = autoGrowCollections; |
|
|
|
|
this.maximumAutoGrowSize = maximumAutoGrowSize; |
|
|
|
|
this.maximumExpressionLength = maximumExpressionLength; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -146,4 +173,12 @@ public class SpelParserConfiguration {
@@ -146,4 +173,12 @@ public class SpelParserConfiguration {
|
|
|
|
|
return this.maximumAutoGrowSize; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the maximum number of characters that a SpEL expression can contain. |
|
|
|
|
* @since 5.2.25 |
|
|
|
|
*/ |
|
|
|
|
public int getMaximumExpressionLength() { |
|
|
|
|
return this.maximumExpressionLength; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|