Skip to content
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

Strange $ escape or "too many lost \" #1219

Open
magicprinc opened this issue Sep 6, 2024 · 4 comments
Open

Strange $ escape or "too many lost \" #1219

magicprinc opened this issue Sep 6, 2024 · 4 comments

Comments

@magicprinc
Copy link

magicprinc commented Sep 6, 2024

$ 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
#746
#1056

@magicprinc magicprinc changed the title Strange $ escape Strange $ escape or lost \ Sep 6, 2024
@magicprinc magicprinc changed the title Strange $ escape or lost \ Strange $ escape or "too many lost \" Sep 7, 2024
@radcortez
Copy link
Member

@dmlloyd want to reply? :)

@dmlloyd
Copy link
Contributor

dmlloyd commented Sep 12, 2024

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.

@magicprinc
Copy link
Author

Quarkus uses SmallRye Config and has the same problem and no one complains? 😭

@radcortez
Copy link
Member

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.

I'll see what I can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants