Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8208

Requests with encoded special characters fail with IllegalArgument exception in SwaggerUiResourceLocator

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.5
    • Fix Version/s: 3.3.6, 3.2.13
    • Component/s: JAX-RS
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Requests with url encoded strings in the url (like spaces) break with an illegal argument exception from SwaggerUiResourceLocator.  For some reason the url is decoded by the time it gets to the resource locator so any special characters in the URL cause the request to fail.

      Example Request:

      http://127.0.0.1:9992/rest/assets/by-path/%2FAssets%2Fuploads%2Fcm1%20logo.png

       

      Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 227: jar:file:/E:/DevEnv/80dev/modules/perc-distribution-tree/target/distribution/jetty/base/webapps/Rhythmyx/WEB-INF/lib/swagger-ui-2.2.10-1.jar!/META-INF/resources/webjars/swagger-ui/2.2.10-1/path/itemProperties/Assets/uploads/cm1 logo.png
              at java.net.URI$Parser.fail(URI.java:2848) ~[?:1.8.0_181]
              at java.net.URI$Parser.checkChars(URI.java:3021) ~[?:1.8.0_181]
              at java.net.URI$Parser.parse(URI.java:3058) ~[?:1.8.0_181]
              at java.net.URI.<init>(URI.java:588) ~[?:1.8.0_181]
              at java.net.URI.create(URI.java:850) ~[?:1.8.0_181]
              ... 84 more
      16:41:40,024 ERROR [PSRuntimeExceptionMapper] REST exception mapper mapped exception:
      java.lang.IllegalArgumentException: Illegal character in opaque part at index 227: jar:file:/E:/DevEnv/80dev/modules/perc-distribution-tree/target/distribution/jetty/base/webapps/Rhythmyx/WEB-INF/lib/swagger-ui-2.2.10-1.jar!/META-INF/resources/webjars/swagger-ui/2.2.10-1/path/itemProperties/Assets/uploads/cm1 logo.png
              at java.net.URI.create(URI.java:852) ~[?:1.8.0_181]
              at org.apache.cxf.jaxrs.swagger.SwaggerUiResourceLocator.locate(SwaggerUiResourceLocator.java:54) ~[?:?]
              at org.apache.cxf.jaxrs.swagger.SwaggerUiResourceLocator.exists(SwaggerUiResourceLocator.java:66) ~[?:?]
              at org.apache.cxf.jaxrs.swagger.SwaggerUiResourceFilter.filter(SwaggerUiResourceFilter.java:53) ~[?:?]
              at org.apache.cxf.jaxrs.utils.JAXRSUtils.runContainerRequestFilters(JAXRSUtils.java:1688) ~[?:?]
              at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:109) ~[?:?]
              at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:78) ~[?:?]
              at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) ~[?:?]
              at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) ~[?:?]
              at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) ~[?:?]
              at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) ~[?:?]
              at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) ~[?:?]
              at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160) ~[?:?]
              at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216) ~[?:?]
              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301) ~[?:?]
              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225) ~[?:?]
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) ~[servlet-api-3.1.jar:3.1.0]
              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276) ~[?:?]
              at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at com.percussion.servlets.PSSecurityFilter.doFilter(PSSecurityFilter.java:658) ~[?:?]
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:566) ~[jetty-security-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:203) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:73) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at com.percussion.servlets.PSDispatcherFilter.doFilter(PSDispatcherFilter.java:124) ~[?:?]
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at com.percussion.webdav.PSWebDavRequestFilter.doFilter(PSWebDavRequestFilter.java:90) ~[?:?]
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at com.percussion.servlets.PSSecurityFilter.doFilter(PSSecurityFilter.java:658) ~[?:?]
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at com.percussion.utils.servlet.PSInputValidatorFilter.doFilter(PSInputValidatorFilter.java:478) ~[servlet-utils-8.0.0-SNAPSHOT.jar:?]
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at com.percussion.utils.security.PSSecurityHeaderFilter.doFilter(PSSecurityHeaderFilter.java:95) ~[servlet-utils-8.0.0-SNAPSHOT.jar:?]
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at com.percussion.servlets.PSCharacterSetFilter.doFilter(PSCharacterSetFilter.java:37) ~[?:?]
              at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) ~[jetty-security-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) ~[jetty-servlet-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:219) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:696) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335) ~[jetty-rewrite-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:169) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.Server.handle(Server.java:531) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260) ~[jetty-server-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281) ~[jetty-io-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102) ~[jetty-io-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118) ~[jetty-io-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) ~[jetty-util-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) ~[jetty-util-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) ~[jetty-util-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) ~[jetty-util-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) ~[jetty-util-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760) ~[jetty-util-9.4.10.v20180503.jar:9.4.10.v20180503]
              at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678) ~[jetty-util-9.4.10.v20180503.jar:9.4.10.v20180503]
              at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
      Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 227: jar:file:/E:/DevEnv/80dev/modules/perc-distribution-tree/target/distribution/jetty/base/webapps/Rhythmyx/WEB-INF/lib/swagger-ui-2.2.10-1.jar!/META-INF/resources/webjars/swagger-ui/2.2.10-1/path/itemProperties/Assets/uploads/cm1 logo.png
              at java.net.URI$Parser.fail(URI.java:2848) ~[?:1.8.0_181]
              at java.net.URI$Parser.checkChars(URI.java:3021) ~[?:1.8.0_181]
              at java.net.URI$Parser.parse(URI.java:3058) ~[?:1.8.0_181]
              at java.net.URI.<init>(URI.java:588) ~[?:1.8.0_181]
              at java.net.URI.create(URI.java:850) ~[?:1.8.0_181]
              ... 84 more 

       

      Service config snippet:

      <jaxrs:*features>*

                   <bean class*="org.apache.cxf.jaxrs.swagger.Swagger2Feature">*

                       <property name*="title" ** value="My API"/>*

                       <property name*="version" ** value="5.4.0"/>*

                       <property name*="description" ** value="Public REST API"/>*

                       <property name*="contact" ** value="support@myco"/>*

                  <property name*="scanAllResources" ** value="false"/>*

                   <property name*="runAsFilter" ** value="false" */>

                   <property name*="supportSwaggerUi" ** value="true"/>*

                   <property name*="basePath" ** value="/rest"/>*

                  <property name*="activateOnlyIfJaxrsSupported" ** value="true"/>*

                  <property name*="customizer">*

                      <bean id*="swagger2customizer" ** class="org.apache.cxf.jaxrs.swagger.Swagger2Customizer">*

                          <property name*="dynamicBasePath" ** value="true"/>*

                          <property name*="replaceTags" ** value="true"/>*

                      </bean>

                  </property>

              </bean>

                  <cxf:*logging/>*

              </jaxrs:features>

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              nate_chadwick@percussion.com Nate Chadwick
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: