Skip to content

Commit

Permalink
[FIXED JENKINS-23121] - Add regular expression validator to Collapsin…
Browse files Browse the repository at this point in the history
…gSectionNote
  • Loading branch information
oleg-nenashev committed Jun 10, 2017
1 parent b8f8f17 commit dff97fc
Showing 1 changed file with 21 additions and 0 deletions.
Expand Up @@ -29,11 +29,17 @@
import hudson.console.ConsoleAnnotationDescriptor;
import hudson.console.ConsoleAnnotator;
import hudson.console.ConsoleNote;
import hudson.util.FormValidation;
import java.lang.reflect.Array;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import net.sf.json.JSONObject;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

/**
Expand Down Expand Up @@ -167,5 +173,20 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti

return true;
}

@Restricted(NoExternalUse.class)
public FormValidation doCheckSectionStartPattern(@QueryParameter String sectionStartPattern) {
try {
Pattern.compile(sectionStartPattern);
} catch (PatternSyntaxException exception) {
return FormValidation.error(exception.getDescription());
}
return FormValidation.ok();
}

@Restricted(NoExternalUse.class)
public FormValidation doCheckSectionEndPattern(@QueryParameter String sectionEndPattern) {
return doCheckSectionStartPattern(sectionEndPattern);
}
}
}

0 comments on commit dff97fc

Please sign in to comment.