mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
[FIXED HUDSON-4637] Added check for leading slash, backslash, or Windows drive string in Alternate Settings File textfield, to reinforce that this is, in fact, a relative path in the workspace.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@22659 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
4939d15f05
commit
2b12abbda2
2 files changed
+25
-1
No files matched your search
@@ -34,6 +34,8 @@ import hudson.search.SearchIndexBuilder;
|
||||
import hudson.tasks.Maven.MavenInstallation;
|
||||
import hudson.tasks.*;
|
||||
import hudson.tasks.junit.JUnitResultArchiver;
|
||||
import static hudson.Util.fixEmpty;
|
||||
import static hudson.Util.fixEmptyAndTrim;
|
||||
import hudson.util.CopyOnWriteMap;
|
||||
import hudson.util.DescribableList;
|
||||
import hudson.util.Function1;
|
||||
@@ -701,6 +703,28 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
|
||||
return FormValidation.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the provided file is a relative path. And check that it exists, just in case.
|
||||
*/
|
||||
public FormValidation doCheckFileRelative(@QueryParameter String value) throws IOException, ServletException {
|
||||
String v = fixEmpty(value);
|
||||
if ((v == null) || (v.length() == 0)) {
|
||||
// Null values are allowed.
|
||||
return FormValidation.ok();
|
||||
}
|
||||
if ((v.startsWith("/")) || (v.startsWith("\\")) || (v.matches("^\\w\\:\\\\.*"))) {
|
||||
return FormValidation.error("Alternate settings file must be a relative path.");
|
||||
}
|
||||
|
||||
MavenModuleSetBuild lb = getLastBuild();
|
||||
if (lb!=null) {
|
||||
FilePath ws = lb.getModuleRoot();
|
||||
if(ws!=null)
|
||||
return ws.validateRelativePath(value,true,true);
|
||||
}
|
||||
return FormValidation.ok();
|
||||
}
|
||||
|
||||
public TopLevelItemDescriptor getDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user