[MAGNOLIA-3739] Freemarker ?url builtin doesn't work in Magnolia Created: 22/Jun/11  Updated: 06/Dec/13  Resolved: 08/Aug/13

Status: Closed
Project: Magnolia
Component/s: freemarker
Affects Version/s: 4.4.4
Fix Version/s: 4.5.11, 5.1

Type: Bug Priority: Neutral
Reporter: Sean McMains Assignee: Ondrej Chytil
Resolution: Fixed Votes: 0
Labels: freemarker
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File freemarker-configuration-patch.diff    
Issue Links:
duplicate
is duplicated by MAGNOLIA-1184 FreemarkerUtil should set the urlEsca... Closed
is duplicated by MAGNOLIA-3286 Add new setting URLEscapingCharset to... Closed
Template:
Patch included:
Yes
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
Testcase included:
Yes

 Description   

Steps to reproduce:

1. Use the url built-in to render a variable in a freemarker template ("title?url", for example)

Expected result:

The template should output a URL-encoded version of the title variable

Actual result:

To do URL encoding, the framework that encloses FreeMarker must specify the output encoding or the URL encoding charset, so ask the programmers to fix it. Or, as a last chance, you can set the url_encoding_charset setting in the template, e.g. <#setting url_escaping_charset='ISO-8859-1'>, or give the charset explicitly to the buit-in, e.g. foo?url('ISO-8859-1').
The problematic instruction:
----------
==> ${title?url} [on line 62, column 9 in templating-kit/templates/global/mainAreaIntro.ftl]
 in include def.mainArea.intro.template [on line 2, column 5 in templating-kit/templates/global/mainArea.ftl]
 in include "../global/mainArea.ftl" [on line 4, column 5 in templating-kit/templates/content/mainArea.ftl]
 in include def.mainArea.template [on line 48, column 21 in templating-kit/templates/main.ftl]
----------

One can work around this by setting the encoding in the template, but one shouldn't have to.

Patch with fix and test case included.


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