Uploaded image for project: 'Magnolia REST Framework'
  1. Magnolia REST Framework
  2. MGNLREST-394

REST requests with Umlaut characters in URL fail

    XMLWordPrintable

Details

    Description

      Steps to reproduce

      Expected behaviour

      HTTP status 200

      Expected behaviour

      HTTP status 404

      Initial analysis

      The root cause is RestDispatcherServlet constructing a not correctly URL encoded URL by using HttpServletRequest.getPathInfo, which returns a decoded string.

      The following patch made the problem go away. There might be better ways to fix this thought.

      @@ -197,7 +197,7 @@
                   EnvironmentContextPerThread.runInEnvironmentContext(environment, () -> onEnvironmentAdded(environment));
               }
       
      -        final String relativePath = httpServletRequest.getPathInfo();
      +        final String relativePath = StringUtils.substringAfter(httpServletRequest.getRequestURL().toString(), httpServletRequest.getServletPath());
               HttpServletRequest environmentRequest = relativePath.startsWith("/environments") ? httpServletRequest :
                       new HttpServletRequestWrapper(httpServletRequest) {
                           @Override
       

       

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                mduerig Michael Duerig
                mduerig Michael Duerig
                Foundation
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD

                    Time Tracking

                      Estimated:
                      Original Estimate - Not Specified
                      Not Specified
                      Remaining:
                      Remaining Estimate - Not Specified
                      Not Specified
                      Logged:
                      Time Spent - 1h
                      1h