[MAGNOLIA-3310] UnicodeNormalizationFilter seems to be messing up the virtualUriMappings Created: 06/Oct/10  Updated: 20/Feb/15  Resolved: 26/Oct/10

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 4.3.6
Fix Version/s: 4.3.8

Type: Bug Priority: Critical
Reporter: Ernst Bunders Assignee: Ondrej Chytil
Resolution: Fixed Votes: 0
Labels: vpro
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
caused by MAGNOLIA-3337 Request Wrappers hide changes in upst... Closed
relation
is related to MAGNOLIA-3264 UnicodeNormalizerRequestWrapper.getPa... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

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!



 Comments   
Comment by Jan Haderka [ 11/Oct/10 ]

Thanks for the report. Scheduling for the next maintenance release.

Generated at Mon Feb 12 03:45:15 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.