From c2285ece187b4d60fe49dfda78f9916866b3aa87 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 18 Jul 2023 10:41:36 +0300 Subject: [PATCH] Fix path segment handling of encoded values Fixes: #34586 --- .../server/mapping/RequestMapper.java | 2 +- .../vertx/test/matching/PathSegmentTest.java | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 independent-projects/resteasy-reactive/server/vertx/src/test/java/org/jboss/resteasy/reactive/server/vertx/test/matching/PathSegmentTest.java diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java index d3f97a7c4bd48..5d8d5fc931191 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/RequestMapper.java @@ -85,7 +85,7 @@ private RequestMatch mapFromPathMatcher(String path, PathMatcher.PathMatch() { + @Override + public JavaArchive get() { + return ShrinkWrap.create(JavaArchive.class) + .addClass(Resource.class); + } + }); + + @Test + public void testRegularMatch() { + given() + .when().get("/test/list/{seg1}/{seg2}", "key1", "key2") + .then() + .statusCode(200) + .body(is("Path(2): [key1, key2]")); + } + + @Test + public void testEncodedPath() { + given() + .when().get("/test/list/{seg1}/{seg2}", "key/1", "key/2") + .then() + .statusCode(200) + .body(is("Path(2): [key/1, key/2]")); + } + + @Path("/test") + public static class Resource { + @GET + @Path("/list/{primaryKey: .+}") + public String pathAsList(@PathParam("primaryKey") List path) { + return String.format("Path(%d): %s", path.size(), path); + } + } +}