Strange `$` escape or "too many lost `\`"
$ character has special meaning only in front of {
i.e: ${my.var.name}
If alone, $ is (must be) harmless.
But one has to escape this harmless $ very hard :-(
Standalone $ eats too much escaping!
System.setProperty("test.key", " $ ");
assertEquals(" $ ", JProperties.config().getValue("test.key", String.class));// SmallRye Config
System.setProperty("test.key", " \\$ ");
assertEquals(" $ ", JProperties.config().getValue("test.key", String.class));
System.setProperty("test.key", " \\\\$ ");
assertEquals(" \\$ ", JProperties.config().getValue("test.key", String.class));
System.setProperty("test.key", " $$ ");
assertEquals(" $ ", JProperties.config().getValue("test.key", String.class));
System.setProperty("test.key", " \\$$ ");
assertEquals(" $$ ", JProperties.config().getValue("test.key", String.class));
System.setProperty("test.key", " \\\\$$ ");
assertEquals(" \\$$ ", JProperties.config().getValue("test.key", String.class));
Real world example:
macros.key.freemarker.format=\\$\\{%s}
Spring → "\$\{%s}"
SmallRye → "$\{%s}"
See also https://github.com/smallrye/smallrye-config/issues/746 https://github.com/smallrye/smallrye-config/issues/1056
@dmlloyd want to reply? :)
It's more or less permanently broken until we can address this at a lower level. The primary lesson being "never add a syntax preprocessor to an established syntax without understanding that syntax fully".
It should probably be addressed in smallrye-common directly with an option flag to enable (yet another kind of) escaping using backslash, and then encoded directly into that grammar.
Additionally, all code which "senses" expressions by doing e.g. indexOf('$') or anything similar should be nuked from orbit.
Quarkus uses SmallRye Config and has the same problem and no one complains? 😭
It should probably be addressed in
smallrye-commondirectly with an option flag to enable (yet another kind of) escaping using backslash, and then encoded directly into that grammar.
I'll see what I can do.