You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2021/05/02 06:15:02 UTC

[tomee] branch master updated: TOMEE-3170 jaxrs.servlet3.rs.applicationpath applicationPathAnnotationEncodedTest

This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/master by this push:
     new de4ceae  TOMEE-3170 jaxrs.servlet3.rs.applicationpath applicationPathAnnotationEncodedTest
de4ceae is described below

commit de4ceaec7e5e5a831114c163c3bccb166d89834d
Author: David Blevins <da...@gmail.com>
AuthorDate: Sat May 1 23:14:44 2021 -0700

    TOMEE-3170 jaxrs.servlet3.rs.applicationpath applicationPathAnnotationEncodedTest
---
 .../org/apache/openejb/server/rest/RESTService.java  | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
index 360a9a4..bd4c343 100644
--- a/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
+++ b/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java
@@ -70,12 +70,16 @@ import javax.ws.rs.ext.WriterInterceptor;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.UncheckedIOException;
+import java.io.UnsupportedEncodingException;
 import java.lang.annotation.Annotation;
 import java.net.MalformedURLException;
 import java.net.Socket;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -596,6 +600,22 @@ public abstract class RESTService implements ServerService, SelfManaging {
         final ApplicationPath path = appClazz.getAnnotation(ApplicationPath.class);
         if (path != null) {
             String appPath = path.value();
+
+            /*
+             * Percent encoded values are allowed in the value, an implementation will recognize
+             * such values and will not double encode the '%' character.  As such we need to
+             * decode the value now so that we hand it to CXF in raw, not url-safe, form.  CXF
+             * will then encode it to make it url-safe.  If we give CXF the encoded value it will
+             * still encode it and it will be encoded twice, which we do not want.
+             *
+             * Verified by
+             * com.sun.ts.tests.jaxrs.servlet3.rs.applicationpath.JAXRSClient#applicationPathAnnotationEncodedTest_from_standalone
+             */
+            try {
+                appPath = URLDecoder.decode(appPath, StandardCharsets.UTF_8.name());
+            } catch (UnsupportedEncodingException e) {
+                throw new UncheckedIOException(e);
+            }
             if (appPath.endsWith("*")) {
                 appPath = appPath.substring(0, appPath.length() - 1);
             }