apache / apache/logging-log4j2

RegexReplacement static factory method doesn't handle null 'replacement' attribute correctly

Open
#3,215 2 comments 1 reaction 1 assignee Claimed by @jaykataria1111 View on GitHub
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
21h 30m
Merged PRs (30d)
27

Description

RegexReplacement#createRegexReplacement

Static builder method returns `null`if the `regex`attribute is null, but although it logs an error it does not return `null` if the `replacement` attribute is `null`.

```
public static RegexReplacement createRegexReplacement(
@PluginAttribute("regex") final Pattern regex, @PluginAttribute("replacement") final String replacement) {
if (regex == null) {
LOGGER.error("A regular expression is required for replacement");
return null;
}
if (replacement == null) {
LOGGER.error("A replacement string is required to perform replacement");
}
// FIXME: should we use Matcher.quoteReplacement() here?
return new RegexReplacement(regex, replacement);
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.