[MAGNOLIA-5833] In ContentTypeFilter do not decode twice the uri Created: 16/Jul/14  Updated: 17/Jul/14  Resolved: 16/Jul/14

Status: Closed
Project: Magnolia
Component/s: core
Affects Version/s: 5.2
Fix Version/s: 5.2.6, 5.3.2

Type: Bug Priority: Major
Reporter: Eric Hechinger Assignee: Eric Hechinger
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
is causing MGNLDAM-485 Links to documents with % in the file... 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

 Description   

in info.magnolia.cms.filters.ContentTypeFilter line 98

String requestURI = URI.create(ServletUtil.getRequestUri(request)).normalize().getPath();
aggregationState.setCurrentURI(URLDecoder.decode(requestURI, characterEncoding));

the requestURI is decoded twice and this generate error in case of % in the URI:

  • ServletUtil.getRequestUri(request)).normalize() --> .../image%25name.. (%25 is the encoded value of %)
  • .getPath() decode the URI --> .../image%name...
  • performing a URLDecoder.decode(requestURI, characterEncoding) will try to decode the already decoded string -->
    java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "wi"
    	at java.net.URLDecoder.decode(URLDecoder.java:173)
    	at info.magnolia.cms.filters.ContentTypeFilter.doFilter(ContentTypeFilter.java:100)
    	...
    

Generated at Mon Feb 12 04:08:49 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.