Skip to content

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

Description

@magicprinc

$ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions