Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JWT007 opened this issue Nov 18, 2024 · 2 comments
Assignees

Comments

@JWT007
Copy link
Contributor

JWT007 commented Nov 18, 2024

RegexReplacement#createRegexReplacement

Static builder method returns nullif the regexattribute 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);
}
@jaykataria1111
Copy link
Contributor

I can work on this @ppkarwasz feel free too assign this to me :)

JWT007 pushed a commit to JWT007/logging-log4j2 that referenced this issue Feb 11, 2025
…eateRegexReplacement (apache#3215)

* per other builder methods in Log4j a invalid input parameter should result in a fas-fail returning null
@JWT007
Copy link
Contributor Author

JWT007 commented Feb 11, 2025

@ppkarwasz - another small PR - simple fix

@jaykataria1111 - sorry to steal this one from you :( - its been a month and I am trying to close out some of the tickets I created before the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants