Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-3310

UnicodeNormalizationFilter seems to be messing up the virtualUriMappings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • 4.3.8
    • 4.3.6
    • core

      Hello

      I discovered a problem with a virtual uri mapping (of type forward)and the UnicodeNormalizationFilter. What i try to do is the following:
      I have a processed css file that creates the css for a configurable theme. The theme also has a dialog that lets you do all kinds of theme settings.
      The theme css is called with some parameters: the uuid of the page node (to resolve the theme config), and a version parameter (to create uniuque urls for each 'version' of the theme).

      What i want is a virtalUriMapping for this css request, so i can call it without request parameters, making it more cachable. Here is the virtualUriMapping config:
      class: info.magnolia.cms.beans.config.RegexpVirtualURIMapping
      fromURI: ^/themes/([^/])/([0-9])/theme\.css$
      toURI: forward:/resources/vpro/themes/pip/css/theme.css?uuid=$1&lastmodified=$2

      this way i can call my css from the template like: http://localhost:8080/pip/themes/1fb8d8e1-d625-4c24-95a3-904e0102eddd/1286288160080/theme.css
      And the request is forwarded to: /resources/vpro/themes/pip/css/theme.css?uuid=1fb8d8e1-d625-4c24-95a3-904e0102eddd&lastmodified=1286288160080

      So that works but oh lala: when the css model class kicks into action: no more request parameters.
      I put some breakpoints here and there and this is what i see:

      • Every request object is wrapped with a info.magnolia.cms.filters.UnicodeNormalizationFilter.UnicodeNormalizerRequestWrapper by the UnicodeNormalizationFilter filter.
      • this method has a method getParameterMap(), that will look into the wrapped request and fetch the parameters only once.
      • so the first time the VirtualUriFilter is hit, the request wrapper is wrapping a request with no parameters. So the UnicodeNormalizerRequestWrapper.parameters map is empty.
      • The virtualUriMapping is found, the 'forward:' prefix is found, and a request dispatcher is created (with proper requestUri and queryString values).
      • the request is forwarded.
      • At this point i would expect a new request to be created and reinserted into the whole requests handling pipeline. So the next time UnicodeNormalizationFilter is hit, i expect the request to be unwrapped. To my surprise this is not the case. the request is wrapped already, and the wrapper still has the parameters map (with zero entries) from the first request.
        The wrapper now wraps two requests! In it's field 'original' there is the request with url: http://localhost:8080/pip/themes/1fb8d8e1-d625-4c24-95a3-904e0102eddd/1286288160080/theme.css (the first request), and in it's field 'request' (inherited from HttpServletRequestWrapper) a request with url: /resources/vpro/themes/pip/css/theme.css and queryString: uuid=1fb8d8e1-d625-4c24-95a3-904e0102eddd&lastmodified=1286288160080 ( the new request)

      All a bit surprising, and It seems to me that the wrapper is still around at the second request handling. Another thing that seems strange: why does the UnicodeNormalizerRequestWrapper has it's own field for the wrapped request and parameters, as it already extends HttpServletRequestWrapper. It seems to me that the only method that actually adds someting is getHeader(String name).

      And thus: when i switch of the UnicodeNormalization filter: it works!

        Acceptance criteria

              ochytil Ondrej Chytil
              ebunders Ernst Bunders
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD