Skip to content

Commit

Permalink
[JENKINS-38532] When the user supplies parameters with equals separat…
Browse files Browse the repository at this point in the history
…or, rebuild the remaining string
  • Loading branch information
kinow committed Nov 26, 2016
1 parent cc8b2f3 commit cc764d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Expand Up @@ -45,7 +45,7 @@ public abstract class AbstractCascadableParameter extends AbstractScriptablePara
/*
* Serial UID.
*/
private static final long serialVersionUID = 6992538803651219246L;
private static final long serialVersionUID = 3795727126307053346L;
/**
* Map with parameters in the UI.
*/
Expand Down Expand Up @@ -114,7 +114,7 @@ public void doUpdate(String parameters) {
getParameters().clear();
final String[] params = parameters.split(SEPARATOR);
for (String param : params) {
final String[] nameValue = param.split("=");
final String[] nameValue = param.split(EQUALS);
if (nameValue.length == 1) {
final String name = nameValue[0].trim();
if (name.length() > 0)
Expand All @@ -123,6 +123,19 @@ public void doUpdate(String parameters) {
final String name = nameValue[0];
final String value = nameValue[1];
getParameters().put(name, value);
} else if (nameValue.length > 2) {
// TBD: we can eliminate this branch by splitting only on the first EQUALS
final String name = nameValue[0];
final StringBuilder sb = new StringBuilder();
// rebuild the rest of the string, skipping the first value
for (int i = 1; i < nameValue.length; ++i) {
sb.append(nameValue[i]);
if (i+1 < nameValue.length) {
sb.append(EQUALS);
}
}
final String value = sb.toString();
getParameters().put(name, value);
}
}
}
Expand Down
Expand Up @@ -57,11 +57,15 @@ public abstract class AbstractScriptableParameter extends AbstractUnoChoiceParam
/*
* Serial UID.
*/
private static final long serialVersionUID = -6533352776594510145L;
private static final long serialVersionUID = 1322134413144485771L;
/**
* Used to split values that come from the UI via Ajax POST's
*/
protected static final String SEPARATOR = "__LESEP__";
/**
* Used to split values when scripts return values like A=2, B=3.
*/
protected static final String EQUALS = "=";
/**
* Constant used to add the project in the environment variables map.
*/
Expand Down

0 comments on commit cc764d6

Please sign in to comment.