ppkarwasz opened a new issue, #4349:
URL: https://github.com/apache/logging-log4j2/issues/4349

   ## Description
   
   The Javadoc of `MapMessage` and `StructuredDataMessage` says the default 
format renders the data
   "as described in RFC 5424", but the values are not escaped as RFC 5424 
requires.
   
   `MapMessage.appendMap` emits each entry as `key="value"`, appending the 
value with
   `ParameterFormatter.recursiveDeepToString` and no escaping.
   [RFC 5424, section 
6.3.3](https://datatracker.ietf.org/doc/html/rfc5424#section-6.3.3) requires
   `"`, `\` and `]` in a `PARAM-VALUE` to be escaped with a backslash.
   `StructuredDataMessage.getFormattedMessage()` relies on the same rendering.
   
   `Rfc5424Layout` is not affected, since it formats the structured data itself 
and escapes values correctly.
   The default rendering is used by `%m`/`%msg` in Pattern Layout and other 
layouts
   that call `getFormattedMessage()`, where a value containing `"` or `]` 
produces ambiguous output.
   
   Expected behavior, either:
   
   1. escape `"`, `\` and `]` in values in the RFC 5424 rendering, or
   2. reword the Javadoc so it does not claim RFC 5424 compliance.
   
   ## Configuration
   
   **Version:** 2.26.1 (and `2.x` at `d631e82`)
   
   **Operating system:** any
   
   **JDK:** any
   
   ## Logs
   
   None.
   
   ## Reproduction
   
   ```java
   final StringMapMessage message = new StringMapMessage().with("key", "a\" 
other=\"b");
   assertThat(message.getFormattedMessage()).isEqualTo("key=\"a\\\" 
other=\\\"b\"");
   ```
   
   Currently the result is `key="a" other="b"`, which reads as two entries.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to