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 · 0 comments

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);
}
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

1 participant