[MAGNOLIA-8821] VirtualURI mapping to URL with non ascii characters fails Created: 09/Mar/23  Updated: 07/Feb/24  Resolved: 01/Nov/23

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 6.2.29
Fix Version/s: 6.3.0, 6.2.41

Type: Bug Priority: Neutral
Reporter: Jonathan Ayala Assignee: Rishab Dhar
Resolution: Fixed Votes: 2
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Attachments: File test-nonascii.yaml    
Issue Links:
causality
caused by MGNLCACHE-348 VirtualURI mapping to URL with non as... Closed
relation
is related to MGNLCACHE-364 CLONE - Redirect URL being wrongly en... Open
is related to MAGNOLIA-9263 Redirect URL being wrongly encoded In Progress
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MAGNOLIA-9150 Implementation Sub-task Completed Rishab Dhar  
MAGNOLIA-9152 Review Sub-task Completed Robert Šiška  
MAGNOLIA-9153 PiQA Sub-task Completed Robert Šiška  
MAGNOLIA-9154 QA Sub-task Completed Chuong Doan Huy  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Release notes required:
Yes
Date of First Response:
Epic Link: Support
Sprint: DevX 49
Story Points: 3
Team: DeveloperX
Work Started:

 Description   

Steps to reproduce

  1. Create a page with name page-with-non-ascii-ä
  2. Add the attached VirtualURI mapping test-nonascii.yaml
  3. Send request: http://localhost:8080/magnoliaAuthor/somepath/page-with-non-ascii-ä

Expected results

We're redirected to http://localhost:8080/magnoliaAuthor/page-with-non-ascii-ä

Actual results

Encoding of non-ascii character fails and we are redirected to http://localhost:8080/magnoliaAuthor/page-with-non-ascii-%E4 instead, which returns a 404

Workaround

Development notes

Property magnolia_utf8_enabled is set to true



 Comments   
Comment by Samuli Saarinen [ 10/Mar/23 ]

When creating the fix it might be good to consider that the redirected url can have query parameters as well that can contain non-ascii values also

Comment by David Martin [ 27/Jul/23 ]

Hi Magnolia Folks, 

Any news on when this issue will be fixed? 

We can workround it, but it's rather annoying to have to workround relatively fundamental issues like special characters in the URL that the Magnolia platform should handle out of the box.

Cheers, Dave

Comment by Rishab Dhar [ 18/Oct/23 ]

The issue was caused by MGNLCACHE-300 which used the below API to escape CRLF sequences in sanitization process from the redirect headers sent by the Magnolia. 

org.apache.commons.lang.StringEscapeUtils.escapeJava

This API caused the non-ASCII characters to also be escaped in the returned location header for the redirects.

An alternate fix uses the RegexUtils API to explicitly escape only CRLF sequences from the returned header.

The bug affects both 6.2 and 6.3

Comment by Rishab Dhar [ 20/Oct/23 ]

Created MGNLCACHE-348 for the fix to the cache module.

Comment by Christoph Meier [ 26/Oct/23 ]

It looks like the "fix" now also URL-encodes ;jsessionid=238029384 in some cases.
The ; and the = ...
See it.info.magnolia.eeintegrationtests.EEBasicTest#loginOnAuthorInstanceWithSuperuser

I'm not sure whether that's fine.

Comment by Rishab Dhar [ 30/Oct/23 ]

The original fix for VirtualURI mapping to URL UTF-8 encoded the entire URL of the format 

<scheme>://<username>:<password>@<host>:<port>/<path>;<parameters>?<query>#<fragment>

which resulted in the ; and = in the parameters to be also be UTF-8 encoded, and the ? and = in query parameters to be also be encoded.

However, this caused failed redirection in it.info.magnolia.eeintegrationtests.EEBasicTest#loginOnAuthorInstanceWithSuperuser where the ; and = in the jsessionid parameter. And in it.info.magnolia.eeintegrationtests.GdprTest#formConsent the ? and =.

This and this PR escape all the separators for path and query params and the fragment in here.

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