Skip to content

Commit 75f26ee

Browse files
committed
Fix FreeMarker escaping regression for messages and separators
Issue: SPR-16951 (cherry picked from commit 08e1c8c)
1 parent 4402336 commit 75f26ee

File tree

1 file changed

+42
-42
lines changed
  • spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker

1 file changed

+42
-42
lines changed

spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker/spring.ftl

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,68 +25,68 @@
2525
*
2626
* Macro to translate a message code into a message.
2727
-->
28-
<#macro message code>${springMacroRequestContext.getMessage(code)}</#macro>
28+
<#macro message code>${springMacroRequestContext.getMessage(code)?no_esc}</#macro>
2929

3030
<#--
3131
* messageText
3232
*
3333
* Macro to translate a message code into a message,
3434
* using the given default text if no message found.
3535
-->
36-
<#macro messageText code, text>${springMacroRequestContext.getMessage(code, text)}</#macro>
36+
<#macro messageText code, text>${springMacroRequestContext.getMessage(code, text)?no_esc}</#macro>
3737

3838
<#--
3939
* messageArgs
4040
*
4141
* Macro to translate a message code with arguments into a message.
4242
-->
43-
<#macro messageArgs code, args>${springMacroRequestContext.getMessage(code, args)}</#macro>
43+
<#macro messageArgs code, args>${springMacroRequestContext.getMessage(code, args)?no_esc}</#macro>
4444

4545
<#--
4646
* messageArgsText
4747
*
4848
* Macro to translate a message code with arguments into a message,
4949
* using the given default text if no message found.
5050
-->
51-
<#macro messageArgsText code, args, text>${springMacroRequestContext.getMessage(code, args, text)}</#macro>
51+
<#macro messageArgsText code, args, text>${springMacroRequestContext.getMessage(code, args, text)?no_esc}</#macro>
5252

5353
<#--
5454
* theme
5555
*
5656
* Macro to translate a theme message code into a message.
5757
-->
58-
<#macro theme code>${springMacroRequestContext.getThemeMessage(code)}</#macro>
58+
<#macro theme code>${springMacroRequestContext.getThemeMessage(code)?no_esc}</#macro>
5959

6060
<#--
6161
* themeText
6262
*
6363
* Macro to translate a theme message code into a message,
6464
* using the given default text if no message found.
6565
-->
66-
<#macro themeText code, text>${springMacroRequestContext.getThemeMessage(code, text)}</#macro>
66+
<#macro themeText code, text>${springMacroRequestContext.getThemeMessage(code, text)?no_esc}</#macro>
6767

6868
<#--
6969
* themeArgs
7070
*
7171
* Macro to translate a theme message code with arguments into a message.
7272
-->
73-
<#macro themeArgs code, args>${springMacroRequestContext.getThemeMessage(code, args)}</#macro>
73+
<#macro themeArgs code, args>${springMacroRequestContext.getThemeMessage(code, args)?no_esc}</#macro>
7474

7575
<#--
7676
* themeArgsText
7777
*
7878
* Macro to translate a theme message code with arguments into a message,
7979
* using the given default text if no message found.
8080
-->
81-
<#macro themeArgsText code, args, text>${springMacroRequestContext.getThemeMessage(code, args, text)}</#macro>
81+
<#macro themeArgsText code, args, text>${springMacroRequestContext.getThemeMessage(code, args, text)?no_esc}</#macro>
8282

8383
<#--
8484
* url
8585
*
8686
* Takes a relative URL and makes it absolute from the server root by
8787
* adding the context root for the web application.
8888
-->
89-
<#macro url relativeUrl extra...><#if extra?? && extra?size!=0>${springMacroRequestContext.getContextUrl(relativeUrl,extra)}<#else>${springMacroRequestContext.getContextUrl(relativeUrl)}</#if></#macro>
89+
<#macro url relativeUrl extra...><#if extra?? && extra?size!=0>${springMacroRequestContext.getContextUrl(relativeUrl,extra)?no_esc}<#else>${springMacroRequestContext.getContextUrl(relativeUrl)?no_esc}</#if></#macro>
9090

9191
<#--
9292
* bind
@@ -109,9 +109,9 @@
109109
* spring.status : a BindStatus instance holding the command object name,
110110
* expression, value, and error messages and codes for the path supplied
111111
*
112-
* @param path : the path (string value) of the value required to bind to.
113-
* Spring defaults to a command name of "command" but this can be overridden
114-
* by user config.
112+
* @param path the path (string value) of the value required to bind to.
113+
* Spring defaults to a command name of "command" but this can be
114+
* overridden by user configuration.
115115
-->
116116
<#macro bind path>
117117
<#if htmlEscape?exists>
@@ -152,8 +152,8 @@
152152
* of a command or bean.
153153
*
154154
* @param path the name of the field to bind to
155-
* @param attributes any additional attributes for the element (such as class
156-
* or CSS styles or size
155+
* @param attributes any additional attributes for the element
156+
* (such as class or CSS styles or size)
157157
-->
158158
<#macro formInput path attributes="" fieldType="text">
159159
<@bind path/>
@@ -169,8 +169,8 @@
169169
* of 'password'.
170170
*
171171
* @param path the name of the field to bind to
172-
* @param attributes any additional attributes for the element (such as class
173-
* or CSS styles or size
172+
* @param attributes any additional attributes for the element
173+
* (such as class or CSS styles or size)
174174
-->
175175
<#macro formPasswordInput path attributes="">
176176
<@formInput path, attributes, "password"/>
@@ -184,8 +184,8 @@
184184
* the formInput macro with a 'type' parameter of 'hidden'.
185185
*
186186
* @param path the name of the field to bind to
187-
* @param attributes any additional attributes for the element (such as class
188-
* or CSS styles or size
187+
* @param attributes any additional attributes for the element
188+
* (such as class or CSS styles or size)
189189
-->
190190
<#macro formHiddenInput path attributes="">
191191
<@formInput path, attributes, "hidden"/>
@@ -197,8 +197,8 @@
197197
* Display a text area and bind it to an attribute of a command or bean.
198198
*
199199
* @param path the name of the field to bind to
200-
* @param attributes any additional attributes for the element (such as class
201-
* or CSS styles or size
200+
* @param attributes any additional attributes for the element
201+
* (such as class or CSS styles or size)
202202
-->
203203
<#macro formTextarea path attributes="">
204204
<@bind path/>
@@ -214,8 +214,8 @@ ${stringStatusValue}</textarea>
214214
*
215215
* @param path the name of the field to bind to
216216
* @param options a map (value=label) of all the available options
217-
* @param attributes any additional attributes for the element (such as class
218-
* or CSS styles or size
217+
* @param attributes any additional attributes for the element
218+
* (such as class or CSS styles or size)
219219
-->
220220
<#macro formSingleSelect path options attributes="">
221221
<@bind path/>
@@ -240,8 +240,8 @@ ${stringStatusValue}</textarea>
240240
*
241241
* @param path the name of the field to bind to
242242
* @param options a map (value=label) of all the available options
243-
* @param attributes any additional attributes for the element (such as class
244-
* or CSS styles or size
243+
* @param attributes any additional attributes for the element
244+
* (such as class or CSS styles or size)
245245
-->
246246
<#macro formMultiSelect path options attributes="">
247247
<@bind path/>
@@ -260,17 +260,17 @@ ${stringStatusValue}</textarea>
260260
*
261261
* @param path the name of the field to bind to
262262
* @param options a map (value=label) of all the available options
263-
* @param separator the html tag or other character list that should be used to
264-
* separate each option. Typically '&nbsp;' or '<br>'
265-
* @param attributes any additional attributes for the element (such as class
266-
* or CSS styles or size
263+
* @param separator the HTML tag or other character list that should be used to
264+
* separate each option (typically '&nbsp;' or '<br>')
265+
* @param attributes any additional attributes for the element
266+
* (such as class or CSS styles or size)
267267
-->
268268
<#macro formRadioButtons path options separator attributes="">
269269
<@bind path/>
270270
<#list options?keys as value>
271271
<#assign id="${status.expression?replace('[','')?replace(']','')}${value_index}">
272272
<input type="radio" id="${id}" name="${status.expression}" value="${value}"<#if stringStatusValue == value> checked="checked"</#if> ${attributes?no_esc}<@closeTag/>
273-
<label for="${id}">${options[value]}</label>${separator}
273+
<label for="${id}">${options[value]}</label>${separator?no_esc}
274274
</#list>
275275
</#macro>
276276

@@ -281,18 +281,18 @@ ${stringStatusValue}</textarea>
281281
*
282282
* @param path the name of the field to bind to
283283
* @param options a map (value=label) of all the available options
284-
* @param separator the html tag or other character list that should be used to
285-
* separate each option. Typically '&nbsp;' or '<br>'
286-
* @param attributes any additional attributes for the element (such as class
287-
* or CSS styles or size
284+
* @param separator the HTML tag or other character list that should be used to
285+
* separate each option (typically '&nbsp;' or '<br>')
286+
* @param attributes any additional attributes for the element
287+
* (such as class or CSS styles or size)
288288
-->
289289
<#macro formCheckboxes path options separator attributes="">
290290
<@bind path/>
291291
<#list options?keys as value>
292292
<#assign id="${status.expression?replace('[','')?replace(']','')}${value_index}">
293293
<#assign isSelected = contains(status.actualValue?default([""]), value)>
294294
<input type="checkbox" id="${id}" name="${status.expression}" value="${value}"<#if isSelected> checked="checked"</#if> ${attributes?no_esc}<@closeTag/>
295-
<label for="${id}">${options[value]}</label>${separator}
295+
<label for="${id}">${options[value]}</label>${separator?no_esc}
296296
</#list>
297297
<input type="hidden" name="_${status.expression}" value="on"/>
298298
</#macro>
@@ -303,8 +303,8 @@ ${stringStatusValue}</textarea>
303303
* Show a single checkbox.
304304
*
305305
* @param path the name of the field to bind to
306-
* @param attributes any additional attributes for the element (such as class
307-
* or CSS styles or size
306+
* @param attributes any additional attributes for the element
307+
* (such as class or CSS styles or size)
308308
-->
309309
<#macro formCheckbox path attributes="">
310310
<@bind path />
@@ -320,12 +320,12 @@ ${stringStatusValue}</textarea>
320320
* Show validation errors for the currently bound field, with
321321
* optional style attributes.
322322
*
323-
* @param separator the html tag or other character list that should be used to
324-
* separate each option. Typically '<br>'.
323+
* @param separator the HTML tag or other character list that should be used to
324+
* separate each option (typically '&nbsp;' or '<br>')
325325
* @param classOrStyle either the name of a CSS class element (which is defined in
326-
* the template or an external CSS file) or an inline style. If the value passed in here
327-
* contains a colon (:) then a 'style=' attribute will be used, else a 'class=' attribute
328-
* will be used.
326+
* the template or an external CSS file) or an inline style. If the value passed
327+
* in here contains a colon (:) then a 'style=' attribute will be used,
328+
* otherwise a 'class=' attribute will be used.
329329
-->
330330
<#macro showErrors separator classOrStyle="">
331331
<#list status.errorMessages as error>
@@ -335,7 +335,7 @@ ${stringStatusValue}</textarea>
335335
<#if classOrStyle?index_of(":") == -1><#assign attr="class"><#else><#assign attr="style"></#if>
336336
<span ${attr}="${classOrStyle}">${error}</span>
337337
</#if>
338-
<#if error_has_next>${separator}</#if>
338+
<#if error_has_next>${separator?no_esc}</#if>
339339
</#list>
340340
</#macro>
341341

0 commit comments

Comments
 (0)