Affects: spring-expression
since 3.2 M2
up to 5.3.19
The problem: Two double quotes are replaced by one double quote - even when literal within single quotes
Expression | Expected | Actual |
---|---|---|
'keep "" two double quotes' | keep "" two double quotes | keep " two double quotes |
"keep '' two single quotes" | keep '' two single quotes | keep ' two single quotes |
According to reference guide only single quotes are allowed for String
literals.
However double quotes are actually supported too (see #14254). And they also replacing two single quotes by one single quote.
- See #14254
- this issue is about double-quotes support
- however it looks like it breaks single quoted literals
https://github.com/spring-projects/spring-framework/blob/4e6ef82d8f3ae7c587e0f1900ca263fd5d7b7f02/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java#L301
https://github.com/spring-projects/spring-framework/blob/b595dc1dfad9db534ca7b9e8f46bb9926b88ab5a/spring-expression/src/main/java/org/springframework/expression/spel/ast/StringLiteral.java#L41
Simple test program:
var p = new SpelExpressionParser();
System.out.println(p.parseExpression("'two double \"\" quotes'").getValue()); // prints two double " quotes
System.out.println(p.parseExpression("\"two single '' quotes\"").getValue()); // prints two single ' quotes
Comment From: sbrannen
This is has been fixed for Spring Framework 6.0.3 and backported to 5.3.25.