Skip to content
Permalink
Browse files

[FIXED JENKINS-13624] BitBucket URL not validated for format.

  • Loading branch information...
Jesse Glick
Jesse Glick committed May 1, 2012
1 parent 2dadbc8 commit 27ce3f7d9033d93cc9d024b0ce8feb5a82430e42
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/main/java/hudson/plugins/mercurial/browser/BitBucket.java
@@ -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;
@@ -12,6 +13,7 @@
import net.sf.json.JSONObject;

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

/**
@@ -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;

0 comments on commit 27ce3f7

Please sign in to comment.
You can’t perform that action at this time.