[ 
https://issues.apache.org/jira/browse/LOG4J2-2968?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Donatien RIVIERE updated LOG4J2-2968:
-------------------------------------
    Description: 
StrSubstitutor does not properly handle a variable default value that contains 
"}" character because it is interpreted as end of the variable default value.

However, this character is part of the pattern layout format, so it is very 
common to expect defining a variable allowing to set a pattern, and fallback to 
a default value containing this kind of character.

Example:

{code:yaml}
  pattern: ${env:MY_PATTERN:-%date{DEFAULT} %level %m%n}
{code}

This pattern is interpreted as below which is obviously wrong (and not a valid 
pattern format).

{code:java}
%date{DEFAULT %level %m%n}
{code}

It would be nice to be able to protected the default value with quotes or any 
begin/end character.

Please find the JUnit test case in attachment.

  was:
StrSubstitutor does not properly handle a variable default value that contains 
"}" character because it is interpreted as end of the variable default value.

However, this character is part of the pattern layout format, so it is very 
common to expect defining a variable allowing to set a pattern, and fallback to 
a default value containing this kind of character.

Example:

{code:yaml}
  pattern: $\{env:MY_PATTERN:-%date{DEFAULT} %level %m%n}
{code}

This pattern is interpreted as below which is obviously wrong (and not a valid 
pattern format).

{code:java}
%date{DEFAULT %level %m%n}
{code}

It would be nice to be able to protected the default value with quotes or any 
begin/end character.

Please find the JUnit test case in attachment.


> Placeholder with default value containing "}"
> ---------------------------------------------
>
>                 Key: LOG4J2-2968
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2968
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Lookups
>    Affects Versions: 2.14.0, 2.13.3
>         Environment: 
>            Reporter: Donatien RIVIERE
>            Priority: Major
>         Attachments: StrSubstitutorPatternDefaultValueTest.java
>
>
> StrSubstitutor does not properly handle a variable default value that 
> contains "}" character because it is interpreted as end of the variable 
> default value.
> However, this character is part of the pattern layout format, so it is very 
> common to expect defining a variable allowing to set a pattern, and fallback 
> to a default value containing this kind of character.
> Example:
> {code:yaml}
>   pattern: ${env:MY_PATTERN:-%date{DEFAULT} %level %m%n}
> {code}
> This pattern is interpreted as below which is obviously wrong (and not a 
> valid pattern format).
> {code:java}
> %date{DEFAULT %level %m%n}
> {code}
> It would be nice to be able to protected the default value with quotes or any 
> begin/end character.
> Please find the JUnit test case in attachment.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to