Skip to content

Commit

Permalink
Quote applicationName in SyslogAppenderFactory
Browse files Browse the repository at this point in the history
When using a user-defined String for the replacement of a regular
expression, we should be quoting it with `Matcher.quoteReplacement`, in
case they use any reserved characters (`/` or `$`).

In this case, we ran in to a problem with a Scala application with a
singleton object for the application, which gets compiled to a class
with a trailing `$`, causing a `StringIndexOutOfBoundsException` here.
  • Loading branch information
nicktelford committed Apr 16, 2014
1 parent e3af383 commit 82779cd
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -189,7 +189,7 @@ public Appender<ILoggingEvent> build(LoggerContext context, String applicationNa
final SyslogAppender appender = new SyslogAppender();
appender.setName("syslog-appender");
appender.setContext(context);
appender.setSuffixPattern(logFormat.replaceAll(LOG_TOKEN_PID, PID).replaceAll(LOG_TOKEN_NAME, applicationName));
appender.setSuffixPattern(logFormat.replaceAll(LOG_TOKEN_PID, PID).replaceAll(LOG_TOKEN_NAME, Matcher.quoteReplacement(applicationName)));
appender.setSyslogHost(host);
appender.setPort(port);
appender.setFacility(facility.toString().toLowerCase(Locale.ENGLISH));
Expand Down

0 comments on commit 82779cd

Please sign in to comment.