| author | akozak | 2011-11-25 03:33:24 (EST) |
|---|---|---|
| committer | Winston Prakash | 2011-12-01 20:47:36 (EST) |
| commit | d2e1c7b6911c7ab38f4a4761212cc44249ffbc32 (patch) (side-by-side diff) | |
| tree | 3bb64bc1ea5f2a94eb6f76f9cd7ab4a8fc337c4d | |
| parent | 42bd7dabdc7f08cc0e9230168157284c0e7cb1d5 (diff) | |
| download | org.eclipse.hudson.core-d2e1c7b6911c7ab38f4a4761212cc44249ffbc32.zip org.eclipse.hudson.core-d2e1c7b6911c7ab38f4a4761212cc44249ffbc32.tar.gz org.eclipse.hudson.core-d2e1c7b6911c7ab38f4a4761212cc44249ffbc32.tar.bz2 | |
Resolve HUDSON-8176 (Matrix Projects variables do not Escaped properly the / character in the URL)
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
3 files changed, 34 insertions, 7 deletions
diff --git a/hudson-core/src/main/java/hudson/matrix/Combination.java b/hudson-core/src/main/java/hudson/matrix/Combination.java index 61ad1f3..962381d 100644 --- a/hudson-core/src/main/java/hudson/matrix/Combination.java +++ b/hudson-core/src/main/java/hudson/matrix/Combination.java @@ -176,13 +176,39 @@ public final class Combination extends TreeMap<String,String> implements Compara * The separator between axis name and value. */ public String toString(char sep1, char sep2) { - StringBuilder buf = new StringBuilder(); - for (Map.Entry<String,String> e : entrySet()) { - if(buf.length()>0) buf.append(sep1); - buf.append(e.getKey()).append(sep2).append(e.getValue()); + return toString(sep1, sep2, false); + } + + /** + * Converts to the ID string representation: + * <tt>axisName=value,axisName=value,...</tt> + * + * @param sep1 The separator between multiple axes. + * @param sep2 The separator between axis name and value. + * @param encodeValue true to encode value {@link Util#rawEncode(String)} + * @return string representation. + */ + public String toString(char sep1, char sep2, boolean encodeValue) { + StringBuilder builder = new StringBuilder(); + if (encodeValue) { + for (Map.Entry<String, String> e : entrySet()) { + if (builder.length() > 0) { + builder.append(sep1); + } + builder.append(e.getKey()).append(sep2).append(Util.rawEncode(e.getValue())); + } + } else { + for (Map.Entry<String, String> e : entrySet()) { + if (builder.length() > 0) { + builder.append(sep1); + } + builder.append(e.getKey()).append(sep2).append(e.getValue()); + } } - if(buf.length()==0) buf.append("default"); // special case to avoid 0-length name. - return buf.toString(); + if (builder.length() == 0) { + builder.append("default"); // special case to avoid 0-length name. + } + return builder.toString(); } @Override diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java index 47ff46f..7f3431c 100644 --- a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java +++ b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java @@ -396,6 +396,7 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui return child.isDirectory() && !child.getName().startsWith("axis-"); } }); + //TODO seems oldDir is always null and old matrix configuration is not cleared. if (oldDirs != null) { // rename the old directory to the new one for (File dir : oldDirs) { diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixRun.java b/hudson-core/src/main/java/hudson/matrix/MatrixRun.java index e8e4dd2..42ef5b0 100644 --- a/hudson-core/src/main/java/hudson/matrix/MatrixRun.java +++ b/hudson-core/src/main/java/hudson/matrix/MatrixRun.java @@ -147,7 +147,7 @@ public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> { if(useShortWorkspaceName) { subtree = getParent().getDigestName(); } else { - subtree = getParent().getCombination().toString('/','/'); + subtree = getParent().getCombination().toString('/','/', true); } String customWorkspace = getParent().getParent().getCustomWorkspace(); |

