提交 2b12abbd 编写于 作者: A abayer

[FIXED HUDSON-4637] Added check for leading slash, backslash, or Windows drive...

[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
上级 4939d15f
......@@ -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;
}
......
......@@ -73,7 +73,7 @@ THE SOFTWARE.
help="/plugin/maven-plugin/alternate-settings.html">
<f:textbox name="alternateSettings"
value="${it.alternateSettings}"
checkUrl="'checkFileInWorkspace?value='+escape(this.value)"
checkUrl="'checkFileRelative?value='+escape(this.value)"
/>
</f:entry>
<f:optionalBlock name="maven.incrementalBuild"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册