Skip to content

Commit

Permalink
[FIXED JENKINS-13624] BitBucket URL not validated for format.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Glick committed May 1, 2012
1 parent 2dadbc8 commit 27ce3f7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/hudson/plugins/mercurial/browser/BitBucket.java
Expand Up @@ -4,6 +4,7 @@
import hudson.model.Descriptor;
import hudson.plugins.mercurial.MercurialChangeSet;
import hudson.scm.RepositoryBrowser;
import hudson.util.FormValidation;

import java.io.IOException;
import java.net.MalformedURLException;
Expand All @@ -12,6 +13,7 @@
import net.sf.json.JSONObject;

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

/**
Expand Down Expand Up @@ -69,6 +71,16 @@ public String getDisplayName() {
public @Override BitBucket newInstance(StaplerRequest req, JSONObject json) throws FormException {
return req.bindParameters(BitBucket.class,"bitbucket.");
}

public FormValidation doCheckUrl(@QueryParameter String url) {
if (url.isEmpty()) {
return FormValidation.error("Must enter URL");
} else if (url.matches("https?://bitbucket[.]org/[^/]+/[^/]+/")) {
return FormValidation.ok();
} else {
return FormValidation.warning("Possibly incorrect root URL; expected http://bitbucket.org/USERNAME/REPOS/");
}
}
}

private static final long serialVersionUID = 1L;
Expand Down

0 comments on commit 27ce3f7

Please sign in to comment.