Browse Source

Fix FreeMarker escaping regression for messages and separators

Issue: SPR-16951
pull/1868/head
Juergen Hoeller 8 years ago
parent
commit
08e1c8cfaf
  1. 84
      spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker/spring.ftl

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

@ -25,7 +25,7 @@
* *
* Macro to translate a message code into a message. * Macro to translate a message code into a message.
--> -->
<#macro message code>${springMacroRequestContext.getMessage(code)}</#macro> <#macro message code>${springMacroRequestContext.getMessage(code)?no_esc}</#macro>
<#-- <#--
* messageText * messageText
@ -33,14 +33,14 @@
* Macro to translate a message code into a message, * Macro to translate a message code into a message,
* using the given default text if no message found. * using the given default text if no message found.
--> -->
<#macro messageText code, text>${springMacroRequestContext.getMessage(code, text)}</#macro> <#macro messageText code, text>${springMacroRequestContext.getMessage(code, text)?no_esc}</#macro>
<#-- <#--
* messageArgs * messageArgs
* *
* Macro to translate a message code with arguments into a message. * Macro to translate a message code with arguments into a message.
--> -->
<#macro messageArgs code, args>${springMacroRequestContext.getMessage(code, args)}</#macro> <#macro messageArgs code, args>${springMacroRequestContext.getMessage(code, args)?no_esc}</#macro>
<#-- <#--
* messageArgsText * messageArgsText
@ -48,14 +48,14 @@
* Macro to translate a message code with arguments into a message, * Macro to translate a message code with arguments into a message,
* using the given default text if no message found. * using the given default text if no message found.
--> -->
<#macro messageArgsText code, args, text>${springMacroRequestContext.getMessage(code, args, text)}</#macro> <#macro messageArgsText code, args, text>${springMacroRequestContext.getMessage(code, args, text)?no_esc}</#macro>
<#-- <#--
* theme * theme
* *
* Macro to translate a theme message code into a message. * Macro to translate a theme message code into a message.
--> -->
<#macro theme code>${springMacroRequestContext.getThemeMessage(code)}</#macro> <#macro theme code>${springMacroRequestContext.getThemeMessage(code)?no_esc}</#macro>
<#-- <#--
* themeText * themeText
@ -63,14 +63,14 @@
* Macro to translate a theme message code into a message, * Macro to translate a theme message code into a message,
* using the given default text if no message found. * using the given default text if no message found.
--> -->
<#macro themeText code, text>${springMacroRequestContext.getThemeMessage(code, text)}</#macro> <#macro themeText code, text>${springMacroRequestContext.getThemeMessage(code, text)?no_esc}</#macro>
<#-- <#--
* themeArgs * themeArgs
* *
* Macro to translate a theme message code with arguments into a message. * Macro to translate a theme message code with arguments into a message.
--> -->
<#macro themeArgs code, args>${springMacroRequestContext.getThemeMessage(code, args)}</#macro> <#macro themeArgs code, args>${springMacroRequestContext.getThemeMessage(code, args)?no_esc}</#macro>
<#-- <#--
* themeArgsText * themeArgsText
@ -78,7 +78,7 @@
* Macro to translate a theme message code with arguments into a message, * Macro to translate a theme message code with arguments into a message,
* using the given default text if no message found. * using the given default text if no message found.
--> -->
<#macro themeArgsText code, args, text>${springMacroRequestContext.getThemeMessage(code, args, text)}</#macro> <#macro themeArgsText code, args, text>${springMacroRequestContext.getThemeMessage(code, args, text)?no_esc}</#macro>
<#-- <#--
* url * url
@ -86,7 +86,7 @@
* Takes a relative URL and makes it absolute from the server root by * Takes a relative URL and makes it absolute from the server root by
* adding the context root for the web application. * adding the context root for the web application.
--> -->
<#macro url relativeUrl extra...><#if extra?? && extra?size!=0>${springMacroRequestContext.getContextUrl(relativeUrl,extra)}<#else>${springMacroRequestContext.getContextUrl(relativeUrl)}</#if></#macro> <#macro url relativeUrl extra...><#if extra?? && extra?size!=0>${springMacroRequestContext.getContextUrl(relativeUrl,extra)?no_esc}<#else>${springMacroRequestContext.getContextUrl(relativeUrl)?no_esc}</#if></#macro>
<#-- <#--
* bind * bind
@ -109,9 +109,9 @@
* spring.status : a BindStatus instance holding the command object name, * spring.status : a BindStatus instance holding the command object name,
* expression, value, and error messages and codes for the path supplied * expression, value, and error messages and codes for the path supplied
* *
* @param path : the path (string value) of the value required to bind to. * @param path the path (string value) of the value required to bind to.
* Spring defaults to a command name of "command" but this can be overridden * Spring defaults to a command name of "command" but this can be
* by user config. * overridden by user configuration.
--> -->
<#macro bind path> <#macro bind path>
<#if htmlEscape?exists> <#if htmlEscape?exists>
@ -152,8 +152,8 @@
* of a command or bean. * of a command or bean.
* *
* @param path the name of the field to bind to * @param path the name of the field to bind to
* @param attributes any additional attributes for the element (such as class * @param attributes any additional attributes for the element
* or CSS styles or size * (such as class or CSS styles or size)
--> -->
<#macro formInput path attributes="" fieldType="text"> <#macro formInput path attributes="" fieldType="text">
<@bind path/> <@bind path/>
@ -169,8 +169,8 @@
* of 'password'. * of 'password'.
* *
* @param path the name of the field to bind to * @param path the name of the field to bind to
* @param attributes any additional attributes for the element (such as class * @param attributes any additional attributes for the element
* or CSS styles or size * (such as class or CSS styles or size)
--> -->
<#macro formPasswordInput path attributes=""> <#macro formPasswordInput path attributes="">
<@formInput path, attributes, "password"/> <@formInput path, attributes, "password"/>
@ -184,8 +184,8 @@
* the formInput macro with a 'type' parameter of 'hidden'. * the formInput macro with a 'type' parameter of 'hidden'.
* *
* @param path the name of the field to bind to * @param path the name of the field to bind to
* @param attributes any additional attributes for the element (such as class * @param attributes any additional attributes for the element
* or CSS styles or size * (such as class or CSS styles or size)
--> -->
<#macro formHiddenInput path attributes=""> <#macro formHiddenInput path attributes="">
<@formInput path, attributes, "hidden"/> <@formInput path, attributes, "hidden"/>
@ -197,8 +197,8 @@
* Display a text area and bind it to an attribute of a command or bean. * Display a text area and bind it to an attribute of a command or bean.
* *
* @param path the name of the field to bind to * @param path the name of the field to bind to
* @param attributes any additional attributes for the element (such as class * @param attributes any additional attributes for the element
* or CSS styles or size * (such as class or CSS styles or size)
--> -->
<#macro formTextarea path attributes=""> <#macro formTextarea path attributes="">
<@bind path/> <@bind path/>
@ -214,8 +214,8 @@ ${stringStatusValue}</textarea>
* *
* @param path the name of the field to bind to * @param path the name of the field to bind to
* @param options a map (value=label) of all the available options * @param options a map (value=label) of all the available options
* @param attributes any additional attributes for the element (such as class * @param attributes any additional attributes for the element
* or CSS styles or size * (such as class or CSS styles or size)
--> -->
<#macro formSingleSelect path options attributes=""> <#macro formSingleSelect path options attributes="">
<@bind path/> <@bind path/>
@ -240,8 +240,8 @@ ${stringStatusValue}</textarea>
* *
* @param path the name of the field to bind to * @param path the name of the field to bind to
* @param options a map (value=label) of all the available options * @param options a map (value=label) of all the available options
* @param attributes any additional attributes for the element (such as class * @param attributes any additional attributes for the element
* or CSS styles or size * (such as class or CSS styles or size)
--> -->
<#macro formMultiSelect path options attributes=""> <#macro formMultiSelect path options attributes="">
<@bind path/> <@bind path/>
@ -260,17 +260,17 @@ ${stringStatusValue}</textarea>
* *
* @param path the name of the field to bind to * @param path the name of the field to bind to
* @param options a map (value=label) of all the available options * @param options a map (value=label) of all the available options
* @param separator the html tag or other character list that should be used to * @param separator the HTML tag or other character list that should be used to
* separate each option. Typically '&nbsp;' or '<br>' * separate each option (typically '&nbsp;' or '<br>')
* @param attributes any additional attributes for the element (such as class * @param attributes any additional attributes for the element
* or CSS styles or size * (such as class or CSS styles or size)
--> -->
<#macro formRadioButtons path options separator attributes=""> <#macro formRadioButtons path options separator attributes="">
<@bind path/> <@bind path/>
<#list options?keys as value> <#list options?keys as value>
<#assign id="${status.expression?replace('[','')?replace(']','')}${value_index}"> <#assign id="${status.expression?replace('[','')?replace(']','')}${value_index}">
<input type="radio" id="${id}" name="${status.expression}" value="${value}"<#if stringStatusValue == value> checked="checked"</#if> ${attributes?no_esc}<@closeTag/> <input type="radio" id="${id}" name="${status.expression}" value="${value}"<#if stringStatusValue == value> checked="checked"</#if> ${attributes?no_esc}<@closeTag/>
<label for="${id}">${options[value]}</label>${separator} <label for="${id}">${options[value]}</label>${separator?no_esc}
</#list> </#list>
</#macro> </#macro>
@ -281,10 +281,10 @@ ${stringStatusValue}</textarea>
* *
* @param path the name of the field to bind to * @param path the name of the field to bind to
* @param options a map (value=label) of all the available options * @param options a map (value=label) of all the available options
* @param separator the html tag or other character list that should be used to * @param separator the HTML tag or other character list that should be used to
* separate each option. Typically '&nbsp;' or '<br>' * separate each option (typically '&nbsp;' or '<br>')
* @param attributes any additional attributes for the element (such as class * @param attributes any additional attributes for the element
* or CSS styles or size * (such as class or CSS styles or size)
--> -->
<#macro formCheckboxes path options separator attributes=""> <#macro formCheckboxes path options separator attributes="">
<@bind path/> <@bind path/>
@ -292,7 +292,7 @@ ${stringStatusValue}</textarea>
<#assign id="${status.expression?replace('[','')?replace(']','')}${value_index}"> <#assign id="${status.expression?replace('[','')?replace(']','')}${value_index}">
<#assign isSelected = contains(status.actualValue?default([""]), value)> <#assign isSelected = contains(status.actualValue?default([""]), value)>
<input type="checkbox" id="${id}" name="${status.expression}" value="${value}"<#if isSelected> checked="checked"</#if> ${attributes?no_esc}<@closeTag/> <input type="checkbox" id="${id}" name="${status.expression}" value="${value}"<#if isSelected> checked="checked"</#if> ${attributes?no_esc}<@closeTag/>
<label for="${id}">${options[value]}</label>${separator} <label for="${id}">${options[value]}</label>${separator?no_esc}
</#list> </#list>
<input type="hidden" name="_${status.expression}" value="on"/> <input type="hidden" name="_${status.expression}" value="on"/>
</#macro> </#macro>
@ -303,8 +303,8 @@ ${stringStatusValue}</textarea>
* Show a single checkbox. * Show a single checkbox.
* *
* @param path the name of the field to bind to * @param path the name of the field to bind to
* @param attributes any additional attributes for the element (such as class * @param attributes any additional attributes for the element
* or CSS styles or size * (such as class or CSS styles or size)
--> -->
<#macro formCheckbox path attributes=""> <#macro formCheckbox path attributes="">
<@bind path /> <@bind path />
@ -320,12 +320,12 @@ ${stringStatusValue}</textarea>
* Show validation errors for the currently bound field, with * Show validation errors for the currently bound field, with
* optional style attributes. * optional style attributes.
* *
* @param separator the html tag or other character list that should be used to * @param separator the HTML tag or other character list that should be used to
* separate each option. Typically '<br>'. * separate each option (typically '&nbsp;' or '<br>')
* @param classOrStyle either the name of a CSS class element (which is defined in * @param classOrStyle either the name of a CSS class element (which is defined in
* the template or an external CSS file) or an inline style. If the value passed in here * the template or an external CSS file) or an inline style. If the value passed
* contains a colon (:) then a 'style=' attribute will be used, else a 'class=' attribute * in here contains a colon (:) then a 'style=' attribute will be used,
* will be used. * otherwise a 'class=' attribute will be used.
--> -->
<#macro showErrors separator classOrStyle=""> <#macro showErrors separator classOrStyle="">
<#list status.errorMessages as error> <#list status.errorMessages as error>
@ -335,7 +335,7 @@ ${stringStatusValue}</textarea>
<#if classOrStyle?index_of(":") == -1><#assign attr="class"><#else><#assign attr="style"></#if> <#if classOrStyle?index_of(":") == -1><#assign attr="class"><#else><#assign attr="style"></#if>
<span ${attr}="${classOrStyle}">${error}</span> <span ${attr}="${classOrStyle}">${error}</span>
</#if> </#if>
<#if error_has_next>${separator}</#if> <#if error_has_next>${separator?no_esc}</#if>
</#list> </#list>
</#macro> </#macro>

Loading…
Cancel
Save