From 3d568123f35194aaca4ddce7970e2975e47aaaa6 Mon Sep 17 00:00:00 2001 From: lvotypko Date: Tue, 29 Jan 2013 15:51:16 +0100 Subject: [PATCH 1/3] Revert changes which broke backwad compatibility based on discussion in jenkins-dev list --- core/src/main/java/hudson/Util.java | 4 ++-- core/src/test/java/hudson/UtilTest.java | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index ab2f1113e0..e7157cdb6c 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -703,8 +703,8 @@ public class Util { private static final boolean[] uriMap = new boolean[123]; static { String raw = - "! $ '()*+,-. 0123456789 = @ABCDEFGHIJKLMNOPQRSTUVWXYZ _ abcdefghijklmnopqrstuvwxyz"; - // "# %& / :;< >? [\]^ ` {|}~ + "! $ &'()*+,-. 0123456789 = @ABCDEFGHIJKLMNOPQRSTUVWXYZ _ abcdefghijklmnopqrstuvwxyz"; + // "# % / :;< >? [\]^ ` {|}~ // ^--so these are encoded int i; // Encode control chars and space diff --git a/core/src/test/java/hudson/UtilTest.java b/core/src/test/java/hudson/UtilTest.java index d912ab3d74..1a822802af 100644 --- a/core/src/test/java/hudson/UtilTest.java +++ b/core/src/test/java/hudson/UtilTest.java @@ -121,14 +121,6 @@ public class UtilTest extends TestCase { assertEquals(encoded, "http://hudson/job/Hudson%20Job"); } - /** - * Test that Strings that contain ampersand are correctly URL encoded. - */ - public void testEncodeAmpersand() { - final String urlWithAmpersand = "http://hudson/job/Hudson-job/label1&&label2"; - String encoded = Util.encode(urlWithAmpersand); - assertEquals(encoded, "http://hudson/job/Hudson-job/label1%26%26label2"); - } /** * Test the rawEncode() method. @@ -137,7 +129,7 @@ public class UtilTest extends TestCase { String[] data = { // Alternating raw,encoded "abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - "01234567890!@$*()-_=+',.", "01234567890!@$*()-_=+',.", + "01234567890!@$&*()-_=+',.", "01234567890!@$&*()-_=+',.", " \"#%/:;<>?", "%20%22%23%25%2F%3A%3B%3C%3E%3F", "[\\]^`{|}~", "%5B%5C%5D%5E%60%7B%7C%7D%7E", "d\u00E9velopp\u00E9s", "d%C3%A9velopp%C3%A9s", From f2de2aca92494f335536a8443788ba0c1603bf1b Mon Sep 17 00:00:00 2001 From: lvotypko Date: Wed, 30 Jan 2013 13:16:41 +0100 Subject: [PATCH 2/3] Revert javadoc too. --- core/src/main/java/hudson/Util.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index e7157cdb6c..422116b185 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -719,11 +719,9 @@ public class Util { * Encode a single path component for use in an HTTP URL. * Escapes all non-ASCII, general unsafe (space and "#%<>[\]^`{|}~) * and HTTP special characters (/;:?) as specified in RFC1738. - * Also escapes & for convenience. - * (so alphanumeric and !@$*()-_=+',. are not encoded) + * (so alphanumeric and !@$&*()-_=+',. are not encoded) * Note that slash(/) is encoded, so the given string should be a * single path component used in constructing a URL. - * Do not use this method for encoding query parameters. * Method name inspired by PHP's rawurlencode. */ public static String rawEncode(String s) { From df00baea5a766685c3108bf8fa308fc848e645a2 Mon Sep 17 00:00:00 2001 From: lvotypko Date: Mon, 11 Feb 2013 11:35:15 +0100 Subject: [PATCH 3/3] Revert changes in method encode too. --- core/src/main/java/hudson/Util.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 422116b185..ac19fe3918 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -678,7 +678,7 @@ public class Util { for (int i = 0; i < s.length(); i++) { int c = s.charAt(i); - if (c<128 && (c!=' ' && c!='&')) { + if (c<128 && c!=' ') { out.append((char) c); } else { // 1 char -> UTF8