-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expression STRICT_ESCAPES mode #344
base: main
Are you sure you want to change the base?
Conversation
There are some subtle problems with this approach, but before I get into it, I want to ask: is there a reason why we don't change this line in Expression expression = Expression.compile(escapeDollarIfExists(configValue.getValue()), LENIENT_SYNTAX, NO_TRIM,
NO_SMART_BRACES, DOUBLE_COLON); |
One of the reasons was that it doesn't play well with the comma escape for multiple elements in arrays, like |
Sure, I can see that. However it is not possible to unambiguously discriminate in this case, so I think we may just have to "eat it" and require double-escaping for lists in order to truly fix the problem, or else come up with a single expression escaping scheme that also covers the list case (which is much harder than it would seem, since lists of lists are a thing). |
That is something we can explore. Still, since we mandate the brackets to define the expression, I think the On another note, what are the subtle issues with this approach? :) |
Basically, this is a state machine (a DFA), and each state is well-defined (basically meaning, every character path is evaluated and tested for each state). By adding a boolean flag which sometimes changes the code path, the number of states has doubled. Unless every new state is tested (or proven not to be enterable) then there is a lacking of test coverage. |
I think you're right about |
Of course then I'll have to find all the places where I said that |
I added the flag make the checks easiers, but I think it could be writtent without it.
Ok, so we have two options: Either we go with the new expression mode and cover our current expected cases or We turn on |
Or we could still use it if |
Proposal of a new escape expressions mode (
STRICT_ESCAPES
) to help with:$
escape or "too many lost\
" smallrye-config#1219The following rules are applied when the mode is active:
This also allows the removal of the workaround for MP Config:
https://github.com/smallrye/smallrye-config/blob/d447b0c346e39a09c6d07c7d5ce8186bd4154037/implementation/src/main/java/io/smallrye/config/ExpressionConfigSourceInterceptor.java#L102-L123