diff --git a/ballerina-tests/http-advanced-tests/Ballerina.toml b/ballerina-tests/http-advanced-tests/Ballerina.toml index e75aa74c05..7af858c217 100644 --- a/ballerina-tests/http-advanced-tests/Ballerina.toml +++ b/ballerina-tests/http-advanced-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_advanced_tests" -version = "2.7.8" +version = "2.7.9" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.8" +version = "2.7.9" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.8.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.9-SNAPSHOT.jar" diff --git a/ballerina-tests/http-advanced-tests/Dependencies.toml b/ballerina-tests/http-advanced-tests/Dependencies.toml index 16139137af..696ff52c81 100644 --- a/ballerina-tests/http-advanced-tests/Dependencies.toml +++ b/ballerina-tests/http-advanced-tests/Dependencies.toml @@ -73,7 +73,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -105,7 +105,7 @@ modules = [ [[package]] org = "ballerina" name = "http_advanced_tests" -version = "2.7.8" +version = "2.7.9" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "file"}, @@ -125,7 +125,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-client-tests/Ballerina.toml b/ballerina-tests/http-client-tests/Ballerina.toml index fe395500cf..73d9cdf9b7 100644 --- a/ballerina-tests/http-client-tests/Ballerina.toml +++ b/ballerina-tests/http-client-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_client_tests" -version = "2.7.8" +version = "2.7.9" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.8" +version = "2.7.9" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.8.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.9-SNAPSHOT.jar" diff --git a/ballerina-tests/http-client-tests/Dependencies.toml b/ballerina-tests/http-client-tests/Dependencies.toml index 1c9014fec3..b38d601109 100644 --- a/ballerina-tests/http-client-tests/Dependencies.toml +++ b/ballerina-tests/http-client-tests/Dependencies.toml @@ -70,7 +70,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -102,7 +102,7 @@ modules = [ [[package]] org = "ballerina" name = "http_client_tests" -version = "2.7.8" +version = "2.7.9" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "http"}, @@ -121,7 +121,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-dispatching-tests/Ballerina.toml b/ballerina-tests/http-dispatching-tests/Ballerina.toml index d28f7bb55f..9bf5ffee9d 100644 --- a/ballerina-tests/http-dispatching-tests/Ballerina.toml +++ b/ballerina-tests/http-dispatching-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_dispatching_tests" -version = "2.7.8" +version = "2.7.9" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.8" +version = "2.7.9" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.8.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.9-SNAPSHOT.jar" diff --git a/ballerina-tests/http-dispatching-tests/Dependencies.toml b/ballerina-tests/http-dispatching-tests/Dependencies.toml index 5717f4cda7..fb200860ca 100644 --- a/ballerina-tests/http-dispatching-tests/Dependencies.toml +++ b/ballerina-tests/http-dispatching-tests/Dependencies.toml @@ -67,7 +67,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -99,7 +99,7 @@ modules = [ [[package]] org = "ballerina" name = "http_dispatching_tests" -version = "2.7.8" +version = "2.7.9" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "http_test_common"}, @@ -120,7 +120,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-dispatching-tests/tests/service_dispatching_uri_template_matching.bal b/ballerina-tests/http-dispatching-tests/tests/service_dispatching_uri_template_matching.bal index 934921d299..f31eb292dd 100644 --- a/ballerina-tests/http-dispatching-tests/tests/service_dispatching_uri_template_matching.bal +++ b/ballerina-tests/http-dispatching-tests/tests/service_dispatching_uri_template_matching.bal @@ -383,6 +383,11 @@ service /encodedUri on utmTestEP { } service /restParam on utmTestEP { + + resource function 'default 'string/[string... aaa]() returns json { + return {aaa: aaa}; + } + resource function 'default 'int/[int... aaa](http:Caller caller) returns error? { http:Response res = new; json responseJson = {aaa: aaa}; @@ -1025,6 +1030,16 @@ function testEncodedPathParams() { } } +@test:Config {} +function testRestParamWithEncodedPathSegments() { +http:Response|error response = utmClient->get("/restParam/string/path%2Fseg/path%20seg/path%2Fseg+123"); + if response is http:Response { + common:assertJsonValue(response.getJsonPayload(), "aaa", ["path/seg", "path seg", "path/seg+123"]); + } else { + test:assertFail(msg = "Found unexpected output type: " + response.message()); + } +} + @test:Config {} function testMultipleIntTypedRestParams() { http:Response|error response = utmClient->get("/restParam/int/345/234/123"); diff --git a/ballerina-tests/http-interceptor-tests/Ballerina.toml b/ballerina-tests/http-interceptor-tests/Ballerina.toml index 359ac109dc..1949c506fc 100644 --- a/ballerina-tests/http-interceptor-tests/Ballerina.toml +++ b/ballerina-tests/http-interceptor-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_interceptor_tests" -version = "2.7.8" +version = "2.7.9" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.8" +version = "2.7.9" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.8.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.9-SNAPSHOT.jar" diff --git a/ballerina-tests/http-interceptor-tests/Dependencies.toml b/ballerina-tests/http-interceptor-tests/Dependencies.toml index 3cc4d564d1..08d2a76558 100644 --- a/ballerina-tests/http-interceptor-tests/Dependencies.toml +++ b/ballerina-tests/http-interceptor-tests/Dependencies.toml @@ -67,7 +67,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -99,7 +99,7 @@ modules = [ [[package]] org = "ballerina" name = "http_interceptor_tests" -version = "2.7.8" +version = "2.7.9" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "http_test_common"}, @@ -115,7 +115,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-misc-tests/Ballerina.toml b/ballerina-tests/http-misc-tests/Ballerina.toml index b8b05506b5..a1a0f20e31 100644 --- a/ballerina-tests/http-misc-tests/Ballerina.toml +++ b/ballerina-tests/http-misc-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_misc_tests" -version = "2.7.8" +version = "2.7.9" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.8" +version = "2.7.9" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.8.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.9-SNAPSHOT.jar" diff --git a/ballerina-tests/http-misc-tests/Dependencies.toml b/ballerina-tests/http-misc-tests/Dependencies.toml index 4c4f2b1df9..c4d945a429 100644 --- a/ballerina-tests/http-misc-tests/Dependencies.toml +++ b/ballerina-tests/http-misc-tests/Dependencies.toml @@ -67,7 +67,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -99,7 +99,7 @@ modules = [ [[package]] org = "ballerina" name = "http_misc_tests" -version = "2.7.8" +version = "2.7.9" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "http_test_common"}, @@ -118,7 +118,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-resiliency-tests/Ballerina.toml b/ballerina-tests/http-resiliency-tests/Ballerina.toml index 846fbf4055..b5d27d3267 100644 --- a/ballerina-tests/http-resiliency-tests/Ballerina.toml +++ b/ballerina-tests/http-resiliency-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_resiliency_tests" -version = "2.7.8" +version = "2.7.9" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.8" +version = "2.7.9" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.8.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.9-SNAPSHOT.jar" diff --git a/ballerina-tests/http-resiliency-tests/Dependencies.toml b/ballerina-tests/http-resiliency-tests/Dependencies.toml index 9f2291536e..e2aa2bc93b 100644 --- a/ballerina-tests/http-resiliency-tests/Dependencies.toml +++ b/ballerina-tests/http-resiliency-tests/Dependencies.toml @@ -67,7 +67,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -99,7 +99,7 @@ modules = [ [[package]] org = "ballerina" name = "http_resiliency_tests" -version = "2.7.8" +version = "2.7.9" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "http_test_common"}, @@ -116,7 +116,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-service-tests/Ballerina.toml b/ballerina-tests/http-service-tests/Ballerina.toml index f8665e9610..3b74361436 100644 --- a/ballerina-tests/http-service-tests/Ballerina.toml +++ b/ballerina-tests/http-service-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_service_tests" -version = "2.7.8" +version = "2.7.9" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.8" +version = "2.7.9" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.8.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.9-SNAPSHOT.jar" diff --git a/ballerina-tests/http-service-tests/Dependencies.toml b/ballerina-tests/http-service-tests/Dependencies.toml index 7e504e7a0c..670f64d520 100644 --- a/ballerina-tests/http-service-tests/Dependencies.toml +++ b/ballerina-tests/http-service-tests/Dependencies.toml @@ -70,7 +70,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -102,7 +102,7 @@ modules = [ [[package]] org = "ballerina" name = "http_service_tests" -version = "2.7.8" +version = "2.7.9" dependencies = [ {org = "ballerina", name = "file"}, {org = "ballerina", name = "http"}, @@ -121,7 +121,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http2-tests/Ballerina.toml b/ballerina-tests/http2-tests/Ballerina.toml index bed6e1a8c4..5b7ad0d390 100644 --- a/ballerina-tests/http2-tests/Ballerina.toml +++ b/ballerina-tests/http2-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http2_tests" -version = "2.7.8" +version = "2.7.9" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.8" +version = "2.7.9" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.8.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.9-SNAPSHOT.jar" diff --git a/ballerina-tests/http2-tests/Dependencies.toml b/ballerina-tests/http2-tests/Dependencies.toml index 796de1c8fc..6166776042 100644 --- a/ballerina-tests/http2-tests/Dependencies.toml +++ b/ballerina-tests/http2-tests/Dependencies.toml @@ -70,7 +70,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -102,7 +102,7 @@ modules = [ [[package]] org = "ballerina" name = "http2_tests" -version = "2.7.8" +version = "2.7.9" dependencies = [ {org = "ballerina", name = "file"}, {org = "ballerina", name = "http"}, @@ -121,7 +121,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.8" +version = "2.7.9" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/changelog.md b/changelog.md index d7260407f3..a882a566ec 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - [Fix the issue of not being able to configure only server name in the secureSocket config](https://github.com/ballerina-platform/ballerina-library/issues/7443) +- [Fix rest path parameter generation with decoded path segments](https://github.com/ballerina-platform/ballerina-library/issues/7430) ## [2.7.8] - 2024-10-16 diff --git a/native/src/main/java/io/ballerina/stdlib/http/api/HttpDispatcher.java b/native/src/main/java/io/ballerina/stdlib/http/api/HttpDispatcher.java index 1dd475d740..3237f2711a 100644 --- a/native/src/main/java/io/ballerina/stdlib/http/api/HttpDispatcher.java +++ b/native/src/main/java/io/ballerina/stdlib/http/api/HttpDispatcher.java @@ -56,6 +56,7 @@ import java.util.Map; import java.util.Objects; import java.util.concurrent.CountDownLatch; +import java.util.stream.Stream; import static io.ballerina.runtime.api.TypeTags.ARRAY_TAG; import static io.ballerina.stdlib.http.api.HttpConstants.AUTHORIZATION_HEADER; @@ -518,18 +519,17 @@ private static void populatePathParams(Resource resource, Object[] paramFeed, if (argumentValue.endsWith(PERCENTAGE)) { argumentValue = argumentValue.replaceAll(PERCENTAGE, PERCENTAGE_ENCODED); } - argumentValue = URLDecoder.decode(argumentValue.replaceAll(PLUS_SIGN, PLUS_SIGN_ENCODED), - StandardCharsets.UTF_8); int paramIndex = actualSignatureParamIndex * 2; Type pathParamType = parameterTypes[actualSignatureParamIndex++]; try { if (pathParamType.getTag() == ARRAY_TAG) { Type elementType = ((ArrayType) pathParamType).getElementType(); - String[] segments = argumentValue.substring(1).split(HttpConstants.SINGLE_SLASH); + String[] segments = Stream.of(argumentValue.substring(1).split(HttpConstants.SINGLE_SLASH)) + .map(HttpDispatcher::decodePathSegment).toArray(String[]::new); paramFeed[paramIndex++] = castParamArray(elementType, segments); } else { - paramFeed[paramIndex++] = castParam(pathParamType.getTag(), argumentValue); + paramFeed[paramIndex++] = castParam(pathParamType.getTag(), decodePathSegment(argumentValue)); } paramFeed[paramIndex] = true; } catch (Exception ex) { @@ -540,6 +540,10 @@ private static void populatePathParams(Resource resource, Object[] paramFeed, } } + private static String decodePathSegment(String pathSegment) { + return URLDecoder.decode(pathSegment.replaceAll(PLUS_SIGN, PLUS_SIGN_ENCODED), StandardCharsets.UTF_8); + } + private static void updateWildcardToken(String wildcardToken, int wildCardIndex, Map> arguments) { if (wildcardToken == null) {