diff --git a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/form/FormParamTest.java b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/form/FormParamTest.java index 935c55248111f..15537bae3675a 100644 --- a/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/form/FormParamTest.java +++ b/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/form/FormParamTest.java @@ -32,15 +32,15 @@ public class FormParamTest { @Test void shouldPassFormParam() { FormClient formClient = RestClientBuilder.newBuilder().baseUri(baseUri).build(FormClient.class); - String result = formClient.directForm("par1", "par2"); - assertThat(result).isEqualTo("root formParam1:par1,formParam2:par2"); + String result = formClient.directForm("par1", "par 2"); + assertThat(result).isEqualTo("root formParam1:par1,formParam2:par 2"); } @Test void shouldPassFormParamFromSubResource() { FormClient formClient = RestClientBuilder.newBuilder().baseUri(baseUri).build(FormClient.class); - String result = formClient.subForm("par1", "par2").form("spar1", "spar2"); - assertThat(result).isEqualTo("sub rootParam1:par1,rootParam2:par2,subParam1:spar1,subParam2:spar2"); + String result = formClient.subForm("par1", "par 2").form("spar1", "spar 2"); + assertThat(result).isEqualTo("sub rootParam1:par1,rootParam2:par 2,subParam1:spar1,subParam2:spar 2"); } public interface FormClient { diff --git a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/URLUtils.java b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/URLUtils.java index 147ed710da741..853aec49f1055 100644 --- a/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/URLUtils.java +++ b/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/util/URLUtils.java @@ -99,35 +99,13 @@ public static String decode(String s, Charset enc, boolean decodeSlash, boolean if (buffer != null) { buffer.setLength(0); } - boolean needToChange = false; int numChars = s.length(); int i = 0; while (i < numChars) { char c = s.charAt(i); - if (c == '+') { - if (formEncoding) { - if (!needToChange) { - if (buffer == null) { - buffer = new StringBuilder(); - } - buffer.append(s, 0, i); - } - buffer.append(' '); - i++; - } else { - i++; - if (needToChange) { - buffer.append(c); - } - } - } else if (c == '%' || c > 127) { - if (!needToChange) { - if (buffer == null) { - buffer = new StringBuilder(); - } - buffer.append(s, 0, i); - needToChange = true; - } + if (c == '%' || c > 127 || c == '+') { + buffer = new StringBuilder(); + buffer.append(s, 0, i); /* * Starting with this instance of a character * that needs to be encoded, process all @@ -232,16 +210,16 @@ public static String decode(String s, Charset enc, boolean decodeSlash, boolean String decoded = new String(bytes, 0, pos, enc); buffer.append(decoded); + return buffer.toString(); } catch (NumberFormatException e) { throw failedToDecodeURL(s, enc, e); } - break; } else { i++; } } - return (needToChange ? buffer.toString() : s); + return s; } private static RuntimeException failedToDecodeURL(String s, Charset enc, Throwable o) {