Skip to content
Permalink
Browse files

Merge pull request #1567 from olivergondza/maven-special-chars-dirty

[JENKINS-26684] Escape special chars in maven build step arguments
  • Loading branch information
olivergondza committed Feb 11, 2015
2 parents 27dbc6b + 58a41bc commit 66b62b9a1f9b68ef5e61304c6aff6e1bef37514e
Showing with 41 additions and 0 deletions.
  1. +4 −0 core/src/main/java/hudson/tasks/Maven.java
  2. +37 −0 test/src/test/java/hudson/tasks/MavenTest.java
@@ -322,6 +322,10 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
wrapUpArguments(args,normalizedTarget,build,launcher,listener);

buildEnvVars(env, mi);

if (!launcher.isUnix()) {
args = args.toWindowsCommand();
}

try {
MavenConsoleAnnotator mca = new MavenConsoleAnnotator(listener.getLogger(),build.getCharset());
@@ -268,4 +268,41 @@ public void testNullHome() throws Exception {
assertEquals("{}", env.toString());
}

@Issue("JENKINS-26684")
@Test public void specialCharsInBuildVariablesPassedAsProperties() throws Exception {
j.configureDefaultMaven();

FreeStyleProject p = j.createFreeStyleProject();
p.getBuildersList().add(new Maven("--help", null));
p.addProperty(new ParametersDefinitionProperty(
new StringParameterDefinition("tilde", "~"),
new StringParameterDefinition("exclamation_mark", "!"),
new StringParameterDefinition("at_sign", "@"),
new StringParameterDefinition("sharp", "#"),
new StringParameterDefinition("dolar", "$"),
new StringParameterDefinition("percent", "%"),
new StringParameterDefinition("circumflex", "^"),
new StringParameterDefinition("ampersand", "&"),
new StringParameterDefinition("asterix", "*"),
new StringParameterDefinition("parentheses", "()"),
new StringParameterDefinition("underscore", "_"),
new StringParameterDefinition("plus", "+"),
new StringParameterDefinition("braces", "{}"),
new StringParameterDefinition("brackets", "[]"),
new StringParameterDefinition("colon", ":"),
new StringParameterDefinition("semicolon", ";"),
new StringParameterDefinition("quote", "\""),
new StringParameterDefinition("apostrophe", "'"),
new StringParameterDefinition("backslash", "\\"),
new StringParameterDefinition("pipe", "|"),
new StringParameterDefinition("angle_brackets", "<>"),
new StringParameterDefinition("comma", ","),
new StringParameterDefinition("period", "."),
new StringParameterDefinition("slash", "/"),
new StringParameterDefinition("question_mark", "?"),
new StringParameterDefinition("space", " ")
));

FreeStyleBuild build = j.buildAndAssertSuccess(p);
}
}

0 comments on commit 66b62b9

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