You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "jvz (via GitHub)" <gi...@apache.org> on 2023/01/23 20:22:12 UTC

[GitHub] [logging-log4j2] jvz opened a new issue, #1223: FormattedMessage doesn't need to use regular expressions

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

   In order to determine which message format syntax to use in `FormattedMessage`, this uses a regular expression. This can be simplified by flipping the ordering to check for a parametrized message first before assuming it's a printf-style message.


-- 
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: notifications-unsubscribe@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] FormattedMessage doesn't need to use regular expressions (logging-log4j2)

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz closed issue #1223: FormattedMessage doesn't need to use regular expressions
URL: https://github.com/apache/logging-log4j2/issues/1223


-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] ppkarwasz commented on issue #1223: FormattedMessage doesn't need to use regular expressions

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #1223:
URL: https://github.com/apache/logging-log4j2/issues/1223#issuecomment-1436460556

   @adwsingh,
   
   Yes, it is a breaking change to silence [Code scanning alert #51](https://github.com/apache/logging-log4j2/security/code-scanning/51): checking for an unescaped `{}` is much faster than checking for a `java.util.Formatter` format specifier.
   
   I believe we can change the documentation to state:
   
   > The message factory supports the following format specifiers:
   > * those specified by `java.text.MessageFormat`,
   > * those specified by `java.util.Formatter`,
   > * `{}` placeholders (cf. `ParameterizedMessage`).
   > Mixing specifier from these 3 categories is not supported.
   
   BTW: The regex we use currently is identical to `java.util.Formatter.formatSpecifier` used by the JRE, so this does not change anything security-wise.


-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] ppkarwasz commented on issue #1223: FormattedMessage doesn't need to use regular expressions

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #1223:
URL: https://github.com/apache/logging-log4j2/issues/1223#issuecomment-1432853620

   @adwsingh, that sounds about right.
   
   I marked you as "assignee" to prevent other contributors to work on it. It's not an obligation.


-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] adwsingh commented on issue #1223: FormattedMessage doesn't need to use regular expressions

Posted by "adwsingh (via GitHub)" <gi...@apache.org>.
adwsingh commented on issue #1223:
URL: https://github.com/apache/logging-log4j2/issues/1223#issuecomment-1434679955

   @ppkarwasz after reading the docs I am not so sure of my implementation anymore as I think it would break users.
   
   In docs we specify,
   
   > The message pattern passed to a [FormattedMessage](https://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/message/FormattedMessage.html) is first checked to see if it is a valid java.text.MessageFormat pattern. If it is, a MessageFormatMessage is used to format it. If not it is next checked to see if it contains any tokens that are valid format specifiers for String.format(). If so, a StringFormattedMessage is used to format it. Finally, if the pattern doesn't match either of those then a ParameterizedMessage is used to format it.
   
   Which means if for a message like `logger.error("Test message {} %s", "abc");`, we would now log `Test message abc %s` instead of `Test message {} abc`


-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] adwsingh commented on issue #1223: FormattedMessage doesn't need to use regular expressions

Posted by "adwsingh (via GitHub)" <gi...@apache.org>.
adwsingh commented on issue #1223:
URL: https://github.com/apache/logging-log4j2/issues/1223#issuecomment-1432725352

   @jvz I was looking into this. How do you suggest we check for a parametrized message, by doing `countArgumentPlaceholders(msg) > 0` ?


-- 
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: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org