From ecef56b546b1a7ae3a8411b3e2af2b64fc72799e Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 4 Jan 2022 09:01:21 +0100 Subject: [PATCH 01/33] WW-5022 Sets escapeHtmlBody to false by default and defines new flag to switch to true globally --- core/pom.xml | 2 +- .../org/apache/struts2/StrutsConstants.java | 14 +- .../org/apache/struts2/components/Anchor.java | 18 +-- .../apache/struts2/components/Component.java | 22 +-- .../org/apache/struts2/components/Submit.java | 18 +-- .../struts2/views/jsp/ui/AnchorTag.java | 18 +-- .../struts2/views/jsp/ui/SubmitTag.java | 8 +- .../struts2/components/ComponentTest.java | 133 +++++++----------- .../struts2/views/jsp/ui/AnchorTest.java | 48 ++++--- .../struts2/views/jsp/ui/CheckboxTest.java | 4 +- .../apache/struts2/views/jsp/ui/FileTest.java | 4 +- .../struts2/views/jsp/ui/SubmitTest.java | 9 +- .../struts2/views/jsp/ui/TextareaTest.java | 4 +- .../src/test/resources/struts-escape-body.xml | 31 ++++ 14 files changed, 168 insertions(+), 165 deletions(-) create mode 100644 core/src/test/resources/struts-escape-body.xml diff --git a/core/pom.xml b/core/pom.xml index 980714243..cd5677742 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -342,7 +342,7 @@ org.slf4j slf4j-simple - true + test + + + + + + + + From 7a696523f02dcf118003a708f4d8b3fcd9d48436 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 4 Jan 2022 19:49:01 +0100 Subject: [PATCH 02/33] WW-5022 Documents that setting escapeHtmlBody per tag takes precedence over global flag --- .../org/apache/struts2/default.properties | 7 +++++- .../struts2/views/jsp/ui/AnchorTest.java | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/core/src/main/resources/org/apache/struts2/default.properties b/core/src/main/resources/org/apache/struts2/default.properties index df4069400..571dcf59e 100644 --- a/core/src/main/resources/org/apache/struts2/default.properties +++ b/core/src/main/resources/org/apache/struts2/default.properties @@ -151,6 +151,11 @@ struts.ui.theme.expansion.token=~~~ ### Sets the default template type. Either ftl, vm, or jsp struts.ui.templateSuffix=ftl +### Sets a global flag which will escape html body of Anchor, Submit and Component tag +### You can control this flag per tag, e.g.: ... +### and this take precedence over the global flag +# struts.ui.escapeHtmlBody=true + ### Configuration reloading ### This will cause the configuration to reload struts.xml when it is changed # struts.configuration.xml.reload=false @@ -230,7 +235,7 @@ struts.handle.exception=true ### Applies maximum length allowed on OGNL expressions for security enhancement (optional) ### -### **WARNING**: If developers enable this option (by configuration) they should make sure that they understand the implications of setting +### **WARNING**: If developers enable this option (by configuration) they should make sure that they understand the implications of setting ### struts.ognl.expressionMaxLength. They must choose a value large enough to permit ALL valid OGNL expressions used within the application. ### Values larger than the 200-400 range have diminishing security value (at which point it is really only a "style guard" for long OGNL ### expressions in an application. Setting a value of null or "" will also disable the feature. diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java index 53fa8ba67..7c3f80d71 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java @@ -298,4 +298,27 @@ public class AnchorTest extends AbstractUITagTest { tag.doEndTag(); } + public void testTagAttributeTakesPrecedenceOverInjectEscapeHtmlBodyFlag() throws Exception { + // given + initDispatcherWithConfigs("struts-default.xml, struts-escape-body.xml"); + String escapeHtmlBody = container.getInstance(String.class, StrutsConstants.STRUTS_UI_ESCAPE_HTML_BODY); + assertEquals("true", escapeHtmlBody); + + createMocks(); + + createAction(); + + AnchorTag tag = createTag(); + tag.setEscapeHtmlBody("false"); + + // when + tag.doStartTag(); + + // then + Anchor component = (Anchor) tag.getComponent(); + assertFalse(component.escapeHtmlBody()); + + tag.doEndTag(); + } + } From effe6875b75ab91fd5b1b83bddd2929d421738f8 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 7 Jan 2022 10:07:13 +0100 Subject: [PATCH 03/33] WW-5022 Pass escapeHtmlBody flag to JavaTemplates tags --- .../org/apache/struts2/components/Anchor.java | 4 ++- .../org/apache/struts2/components/Submit.java | 7 ++-- .../src/site/resources/tags/a-attributes.html | 2 +- .../resources/tags/submit-attributes.html | 2 +- .../views/java/DefaultTagHandlerFactory.java | 13 +++---- .../views/java/simple/AnchorHandler.java | 6 ++-- .../views/java/simple/SimpleTheme.java | 6 ++-- .../views/java/simple/SubmitHandler.java | 14 +++++--- .../struts2/views/java/simple/AnchorTest.java | 36 +++++++++++++++++++ 9 files changed, 69 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/Anchor.java b/core/src/main/java/org/apache/struts2/components/Anchor.java index e00291dd3..ba9d84ac9 100644 --- a/core/src/main/java/org/apache/struts2/components/Anchor.java +++ b/core/src/main/java/org/apache/struts2/components/Anchor.java @@ -112,6 +112,8 @@ public class Anchor extends ClosingUIBean { addParameter("href", ensureAttributeSafelyNotEscaped(builtHref)); } } + + addParameter("escapeHtmlBody", escapeHtmlBody); } @Inject(StrutsConstants.STRUTS_URL_INCLUDEPARAMS) @@ -264,7 +266,7 @@ public class Anchor extends ClosingUIBean { urlProvider.setForceAddSchemeHostAndPort(forceAddSchemeHostAndPort); } - @StrutsTagAttribute(description = "Specifies whether to HTML-escape the tag body or not", type = "Boolean", defaultValue = "true") + @StrutsTagAttribute(description = "Specifies whether to HTML-escape the tag body or not", type = "Boolean", defaultValue = "false") public void setEscapeHtmlBody(boolean escapeHtmlBody) { this.escapeHtmlBody = escapeHtmlBody; } diff --git a/core/src/main/java/org/apache/struts2/components/Submit.java b/core/src/main/java/org/apache/struts2/components/Submit.java index 6a9ce970c..870e8ad0b 100644 --- a/core/src/main/java/org/apache/struts2/components/Submit.java +++ b/core/src/main/java/org/apache/struts2/components/Submit.java @@ -85,8 +85,11 @@ public class Submit extends FormButton { public void evaluateExtraParams() { super.evaluateExtraParams(); - if (src != null) + if (src != null) { addParameter("src", findString(src)); + } + + addParameter("escapeHtmlBody", escapeHtmlBody); } /** @@ -103,7 +106,7 @@ public class Submit extends FormButton { this.src = src; } - @StrutsTagAttribute(description = "Specifies whether to HTML-escape the tag body or not", type = "Boolean", defaultValue = "true") + @StrutsTagAttribute(description = "Specifies whether to HTML-escape the tag body or not", type = "Boolean", defaultValue = "false") public void setEscapeHtmlBody(boolean escapeHtmlBody) { this.escapeHtmlBody = escapeHtmlBody; } diff --git a/core/src/site/resources/tags/a-attributes.html b/core/src/site/resources/tags/a-attributes.html index e9cbb587f..e9fd9089c 100644 --- a/core/src/site/resources/tags/a-attributes.html +++ b/core/src/site/resources/tags/a-attributes.html @@ -112,7 +112,7 @@ escapeHtmlBody false - true + false false Boolean Specifies whether to HTML-escape the tag body or not diff --git a/core/src/site/resources/tags/submit-attributes.html b/core/src/site/resources/tags/submit-attributes.html index 9f790b235..52ed55ad0 100644 --- a/core/src/site/resources/tags/submit-attributes.html +++ b/core/src/site/resources/tags/submit-attributes.html @@ -88,7 +88,7 @@ escapeHtmlBody false - true + false false Boolean Specifies whether to HTML-escape the tag body or not diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTagHandlerFactory.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTagHandlerFactory.java index 4e356c3a6..4110320da 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTagHandlerFactory.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/DefaultTagHandlerFactory.java @@ -22,14 +22,15 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; /** - * Default implementation of TagHandlerFactory + * Default implementation of TagHandlerFactory */ public class DefaultTagHandlerFactory implements TagHandlerFactory { - private static final Logger LOG = LogManager.getLogger(DefaultTagHandlerFactory.class); - - private Class tagHandlerClass; - public DefaultTagHandlerFactory(Class tagHandlerClass) { + private static final Logger LOG = LogManager.getLogger(DefaultTagHandlerFactory.class); + + private final Class tagHandlerClass; + + public DefaultTagHandlerFactory(Class tagHandlerClass) { this.tagHandlerClass = tagHandlerClass; } @@ -41,7 +42,7 @@ public class DefaultTagHandlerFactory implements TagHandlerFactory { } catch (Exception e) { LOG.error("Failed to instantiate tag handler class [{}]", tagHandlerClass.getName(), e); } - + return null; } diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java index 12df24635..405088f0c 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java @@ -45,8 +45,10 @@ public class AnchorHandler extends AbstractTagHandler implements TagGenerator { .addIfExists("tabindex", params.get("tabindex")); start("a", attrs); String body = (String) params.get("body"); - if (StringUtils.isNotEmpty(body)) - characters(body, false); + Boolean escapeHtmlBody = (Boolean) params.get("escapeHtmlBody"); + if (StringUtils.isNotEmpty(body)) { + characters(body, escapeHtmlBody); + } end("a"); } } diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SimpleTheme.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SimpleTheme.java index adfc7f9c8..c65a21c05 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SimpleTheme.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SimpleTheme.java @@ -65,13 +65,13 @@ public class SimpleTheme extends DefaultTheme { setName("simple"); } - private class FactoryList extends ArrayList { + private static class FactoryList extends ArrayList { private static final long serialVersionUID = -1551895041394434032L; - public FactoryList(Class... classes) { + public FactoryList(Class... classes) { super(); - for (Class cls : classes) { + for (Class cls : classes) { add(new DefaultTagHandlerFactory(cls)); } add(new DefaultTagHandlerFactory(XHTMLTagSerializer.class)); diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SubmitHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SubmitHandler.java index 8207d7ba5..27a39d3f3 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SubmitHandler.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/SubmitHandler.java @@ -73,6 +73,7 @@ public class SubmitHandler extends AbstractTagHandler implements TagGenerator { public void generate() throws IOException { Map params = context.getParameters(); String body = (String) params.get("body"); + Boolean escapeHtmlBody = (Boolean) params.get("escapeHtmlBody"); String type = StringUtils.defaultString((String) params.get("type"), "input"); if ("button".equals(type)) { @@ -81,16 +82,19 @@ public class SubmitHandler extends AbstractTagHandler implements TagGenerator { characters(body, false); else if (params.containsKey("label")) { String label = (String) params.get("label"); - if (StringUtils.isNotEmpty(label)) - characters(label, false); + if (StringUtils.isNotEmpty(label)) { + characters(label, escapeHtmlBody); + } } end("button"); } else if ("image".equals(type)) { - if (StringUtils.isNotEmpty(body)) - characters(body, false); + if (StringUtils.isNotEmpty(body)) { + characters(body, escapeHtmlBody); + } end("input"); - } else + } else { end("input"); + } } } } diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java index d727a7440..58709a245 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java @@ -69,6 +69,42 @@ public class AnchorTest extends AbstractTest { assertEquals(expected, output); } + public void testEnableEscapeBody() { + tag.setName("name_"); + tag.setHref("http://sometest.com?ab=10"); + tag.setEscapeHtmlBody(true); + tag.evaluateParams(); + + map.putAll(tag.getParameters()); + context.getParameters().put("body", s("")); + + theme.renderTag(getTagName(), context); + theme.renderTag(getTagName() + "-close", context); + + String output = writer.getBuffer().toString(); + String expected = s("<i class="i-image"/>"); + + assertEquals(expected, output); + } + + public void testDefaultDisabledEscapeBody() { + tag.setName("name_"); + tag.setHref("http://sometest.com?ab=10"); + //tag.setEscapeHtmlBody(true); + tag.evaluateParams(); + + map.putAll(tag.getParameters()); + context.getParameters().put("body", s("")); + + theme.renderTag(getTagName(), context); + theme.renderTag(getTagName() + "-close", context); + + String output = writer.getBuffer().toString(); + String expected = s(""); + + assertEquals(expected, output); + } + @Override protected void setUp() throws Exception { super.setUp(); From 3d39fba0db128093e04111e00cda96f9d1bcd6eb Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 4 Jan 2022 20:20:28 +0100 Subject: [PATCH 04/33] WW-5117 Restores previous behavior where tag was before action on stack --- .../components/template/FreemarkerTemplateEngine.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java b/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java index 3bbd2196b..91e155867 100644 --- a/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java +++ b/core/src/main/java/org/apache/struts2/components/template/FreemarkerTemplateEngine.java @@ -148,16 +148,13 @@ public class FreemarkerTemplateEngine extends BaseTemplateEngine { } }; - LOG.debug("Puts action on the top of ValueStack, just before the tag"); - action = stack.pop(); + LOG.debug("Push tag on top of the stack"); stack.push(templateContext.getTag()); - stack.push(action); try { template.process(model, writer); } finally { - stack.pop(); // removes action - stack.pop(); // removes tag - stack.push(action); // puts back action + LOG.debug("Removes tag from top of the stack"); + stack.pop(); } } From 893a8924eb7b9723df3797bb5060847df61f2094 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 4 Jan 2022 20:21:28 +0100 Subject: [PATCH 05/33] WW-5117 Evaluates dynamic attributes when assigning them to tag Reverts https://github.com/apache/struts/pull/447/commits/8bbe1949e17d58e1b5aef9c71e1279ad12ad7ba7#diff-0a39f082871f48bd14037ab2e3a3911b0b1046506c1d93338024d77d412a7075L305-L309 --- .../java/org/apache/struts2/components/UIBean.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/UIBean.java b/core/src/main/java/org/apache/struts2/components/UIBean.java index 24b47fa14..9ec23d5c7 100644 --- a/core/src/main/java/org/apache/struts2/components/UIBean.java +++ b/core/src/main/java/org/apache/struts2/components/UIBean.java @@ -21,6 +21,7 @@ package org.apache.struts2.components; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.ValueStack; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -30,7 +31,7 @@ import org.apache.struts2.components.template.Template; import org.apache.struts2.components.template.TemplateEngine; import org.apache.struts2.components.template.TemplateEngineManager; import org.apache.struts2.components.template.TemplateRenderingContext; -import org.apache.struts2.dispatcher.StaticContentLoader; +import org.apache.struts2.util.ComponentUtils; import org.apache.struts2.util.TextProviderHelper; import org.apache.struts2.views.annotations.StrutsTagAttribute; import org.apache.struts2.views.util.ContextUtil; @@ -1272,10 +1273,15 @@ public abstract class UIBean extends Component { public void setDynamicAttributes(Map tagDynamicAttributes) { for (Map.Entry entry : tagDynamicAttributes.entrySet()) { - String entryKey = entry.getKey(); + String attrName = entry.getKey(); + String attrValue = entry.getValue(); - if (!isValidTagAttribute(entryKey)) { - dynamicAttributes.put(entryKey, entry.getValue()); + if (!isValidTagAttribute(attrName)) { + if (ComponentUtils.altSyntax(getStack()) && ComponentUtils.isExpression(attrValue)) { + dynamicAttributes.put(attrName, String.valueOf(ObjectUtils.defaultIfNull(findString(attrValue), attrValue))); + } else { + dynamicAttributes.put(attrName, attrValue); + } } } } From a4a4e9e2625a9545766b83cd70d2e9f9fc24f21b Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 5 Jan 2022 20:09:44 +0100 Subject: [PATCH 06/33] WW-5117 Does a conditional evaluation depending on the tag Some tags requires to perform a lazy evaluation which can only happen in ftl template as performing it in the component class is not possible --- .../apache/struts2/components/CheckboxList.java | 16 +++++++++++++--- .../apache/struts2/components/ListUIBean.java | 1 - .../org/apache/struts2/components/Radio.java | 17 ++++++++++++++--- .../org/apache/struts2/components/UIBean.java | 14 ++++++++++++-- .../resources/template/simple/checkboxlist.ftl | 8 ++++---- .../template/simple/dynamic-attributes.ftl | 6 +++++- .../main/resources/template/simple/radiomap.ftl | 5 +++-- 7 files changed, 51 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/CheckboxList.java b/core/src/main/java/org/apache/struts2/components/CheckboxList.java index e83091888..601ce5bdf 100644 --- a/core/src/main/java/org/apache/struts2/components/CheckboxList.java +++ b/core/src/main/java/org/apache/struts2/components/CheckboxList.java @@ -48,7 +48,7 @@ import com.opensymphony.xwork2.util.ValueStack; allowDynamicAttributes = true) public class CheckboxList extends ListUIBean { final public static String TEMPLATE = "checkboxlist"; - + public CheckboxList(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); } @@ -56,9 +56,19 @@ public class CheckboxList extends ListUIBean { protected String getDefaultTemplate() { return TEMPLATE; } - + public void evaluateExtraParams() { super.evaluateExtraParams(); } -} \ No newline at end of file + /** + * Checkboxlist tag requires lazy evaluation as list of tags is dynamically generated using + * + * @return boolean true by default + */ + @Override + protected boolean lazyEvaluation() { + return true; + } + +} diff --git a/core/src/main/java/org/apache/struts2/components/ListUIBean.java b/core/src/main/java/org/apache/struts2/components/ListUIBean.java index 26484f250..bfaffe6f1 100644 --- a/core/src/main/java/org/apache/struts2/components/ListUIBean.java +++ b/core/src/main/java/org/apache/struts2/components/ListUIBean.java @@ -195,7 +195,6 @@ public abstract class ListUIBean extends UIBean { this.listTitle = listTitle; } - public void setThrowExceptionOnNullValueAttribute(boolean throwExceptionOnNullValueAttribute) { this.throwExceptionOnNullValueAttribute = throwExceptionOnNullValueAttribute; } diff --git a/core/src/main/java/org/apache/struts2/components/Radio.java b/core/src/main/java/org/apache/struts2/components/Radio.java index 0315cb65b..ba5eb471f 100644 --- a/core/src/main/java/org/apache/struts2/components/Radio.java +++ b/core/src/main/java/org/apache/struts2/components/Radio.java @@ -57,7 +57,7 @@ import javax.servlet.http.HttpServletResponse; allowDynamicAttributes = true) public class Radio extends ListUIBean { final public static String TEMPLATE = "radiomap"; - + public Radio(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); } @@ -65,8 +65,19 @@ public class Radio extends ListUIBean { protected String getDefaultTemplate() { return TEMPLATE; } - + public void evaluateExtraParams() { super.evaluateExtraParams(); } -} \ No newline at end of file + + /** + * Radio tag requires lazy evaluation as list of tags is dynamically generated using + * + * @return boolean true by default + */ + @Override + protected boolean lazyEvaluation() { + return true; + } + +} diff --git a/core/src/main/java/org/apache/struts2/components/UIBean.java b/core/src/main/java/org/apache/struts2/components/UIBean.java index 9ec23d5c7..a9b8f50f9 100644 --- a/core/src/main/java/org/apache/struts2/components/UIBean.java +++ b/core/src/main/java/org/apache/struts2/components/UIBean.java @@ -1277,8 +1277,8 @@ public abstract class UIBean extends Component { String attrValue = entry.getValue(); if (!isValidTagAttribute(attrName)) { - if (ComponentUtils.altSyntax(getStack()) && ComponentUtils.isExpression(attrValue)) { - dynamicAttributes.put(attrName, String.valueOf(ObjectUtils.defaultIfNull(findString(attrValue), attrValue))); + if (ComponentUtils.altSyntax(getStack()) && ComponentUtils.containsExpression(attrValue) && !lazyEvaluation()) { + dynamicAttributes.put(attrName, ObjectUtils.defaultIfNull(findString(attrValue), attrValue)); } else { dynamicAttributes.put(attrName, attrValue); } @@ -1302,4 +1302,14 @@ public abstract class UIBean extends Component { } } + /** + * Used to avoid evaluating attributes in {@link #evaluateParams()} or {@link #evaluateExtraParams()} + * as evaluation will happen in tag's template + * + * @return boolean false if evaluation should be performed in ftl + */ + protected boolean lazyEvaluation() { + return false; + } + } diff --git a/core/src/main/resources/template/simple/checkboxlist.ftl b/core/src/main/resources/template/simple/checkboxlist.ftl index 3fa27f189..87bef6651 100644 --- a/core/src/main/resources/template/simple/checkboxlist.ftl +++ b/core/src/main/resources/template/simple/checkboxlist.ftl @@ -30,7 +30,7 @@ <#assign itemKeyStr = stack.findString('top')> <#if parameters.listLabelKey??> - <#-- checks the valueStack for the 'valueKey.' The valueKey is then looked-up in the locale + <#-- checks the valueStack for the 'valueKey.' The valueKey is then looked-up in the locale file for it's localized value. This is then used as a label --> <#assign itemValue = struts.getText(stack.findString(parameters.listLabelKey))/> <#elseif parameters.listValue??> @@ -95,9 +95,10 @@ <#include "/${parameters.templateDir}/${parameters.expandTheme}/css.ftl" /> <#include "/${parameters.templateDir}/${parameters.expandTheme}/scripting-events.ftl" /> <#include "/${parameters.templateDir}/${parameters.expandTheme}/common-attributes.ftl" /> + <#global evaluate_dynamic_attributes = true/> <#include "/${parameters.templateDir}/${parameters.expandTheme}/dynamic-attributes.ftl" /> /> - + <#if parameters.id?has_content> for="${parameters.id}-${itemCount}"<#rt/> <#else> @@ -106,11 +107,10 @@ class="checkboxLabel">${itemValue} <#else> -   <#if parameters.disabled!false> disabled="disabled"<#rt/> - /> \ No newline at end of file + /> diff --git a/core/src/main/resources/template/simple/dynamic-attributes.ftl b/core/src/main/resources/template/simple/dynamic-attributes.ftl index 47a91139f..7f15aa48f 100644 --- a/core/src/main/resources/template/simple/dynamic-attributes.ftl +++ b/core/src/main/resources/template/simple/dynamic-attributes.ftl @@ -30,7 +30,11 @@ <#list aKeys?filter(acceptKey) as aKey><#rt/> <#assign keyValue = parameters.dynamicAttributes.get(aKey)/> <#if keyValue?is_string> - <#assign value = struts.translateVariables(keyValue)!keyValue/> + <#if evaluate_dynamic_attributes!false == true> + <#assign value = struts.translateVariables(keyValue)!keyValue/><#rt/> + <#else> + <#assign value = keyValue/><#rt/> + <#else> <#assign value = keyValue?string/> diff --git a/core/src/main/resources/template/simple/radiomap.ftl b/core/src/main/resources/template/simple/radiomap.ftl index 5c37a4b4b..597300e95 100644 --- a/core/src/main/resources/template/simple/radiomap.ftl +++ b/core/src/main/resources/template/simple/radiomap.ftl @@ -27,7 +27,7 @@ <#assign itemKeyStr = stack.findString('top')> <#if parameters.listValueKey??> - <#-- checks the valueStack for the 'valueKey.' The valueKey is then looked-up in the locale + <#-- checks the valueStack for the 'valueKey.' The valueKey is then looked-up in the locale file for it's localized value. This is then used as a label --> <#assign valueKey = stack.findString(parameters.listValueKey)!''/> <#if valueKey?has_content> @@ -94,9 +94,10 @@ <#include "/${parameters.templateDir}/${parameters.expandTheme}/css.ftl" /> <#include "/${parameters.templateDir}/${parameters.expandTheme}/scripting-events.ftl" /> <#include "/${parameters.templateDir}/${parameters.expandTheme}/common-attributes.ftl" /> +<#global evaluate_dynamic_attributes = true/> <#include "/${parameters.templateDir}/${parameters.expandTheme}/dynamic-attributes.ftl" /> /><#rt/> - \ No newline at end of file + From b0e18e9c577d1f8c6c1417a054a11c52cd624234 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 6 Jan 2022 09:03:07 +0100 Subject: [PATCH 07/33] WW-5117 Uses translateVariables instead of findString to allow join expressions --- core/src/main/java/org/apache/struts2/components/UIBean.java | 4 +++- .../java/org/apache/struts2/views/jsp/ui/TextfieldTest.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/UIBean.java b/core/src/main/java/org/apache/struts2/components/UIBean.java index a9b8f50f9..e010eadd4 100644 --- a/core/src/main/java/org/apache/struts2/components/UIBean.java +++ b/core/src/main/java/org/apache/struts2/components/UIBean.java @@ -20,6 +20,7 @@ package org.apache.struts2.components; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.inject.Inject; +import com.opensymphony.xwork2.util.TextParseUtil; import com.opensymphony.xwork2.util.ValueStack; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -1278,7 +1279,8 @@ public abstract class UIBean extends Component { if (!isValidTagAttribute(attrName)) { if (ComponentUtils.altSyntax(getStack()) && ComponentUtils.containsExpression(attrValue) && !lazyEvaluation()) { - dynamicAttributes.put(attrName, ObjectUtils.defaultIfNull(findString(attrValue), attrValue)); + String translated = TextParseUtil.translateVariables('%', attrValue, stack); + dynamicAttributes.put(attrName, ObjectUtils.defaultIfNull(translated, attrValue)); } else { dynamicAttributes.put(attrName, attrValue); } diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java index cf300e806..56d0eaa15 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java @@ -372,7 +372,7 @@ public class TextfieldTest extends AbstractUITagTest { tag.setName("myname"); tag.setValue("%{foo}"); tag.setSize("10"); - tag.setDynamicAttribute(null, "anotherAttr", "%{foo}"); + tag.setDynamicAttribute(null, "anotherAttr", "another_%{foo}"); tag.doStartTag(); setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag). From 9c05422bbe23383cd5a39d89ab14f9e26ac0ffb8 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 13 Jan 2022 10:28:30 +0100 Subject: [PATCH 08/33] WW-5117 Adjusts expression checking --- core/src/main/java/org/apache/struts2/components/UIBean.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/struts2/components/UIBean.java b/core/src/main/java/org/apache/struts2/components/UIBean.java index e010eadd4..85b3d1bb9 100644 --- a/core/src/main/java/org/apache/struts2/components/UIBean.java +++ b/core/src/main/java/org/apache/struts2/components/UIBean.java @@ -32,6 +32,7 @@ import org.apache.struts2.components.template.Template; import org.apache.struts2.components.template.TemplateEngine; import org.apache.struts2.components.template.TemplateEngineManager; import org.apache.struts2.components.template.TemplateRenderingContext; +import org.apache.struts2.dispatcher.StaticContentLoader; import org.apache.struts2.util.ComponentUtils; import org.apache.struts2.util.TextProviderHelper; import org.apache.struts2.views.annotations.StrutsTagAttribute; @@ -1278,7 +1279,7 @@ public abstract class UIBean extends Component { String attrValue = entry.getValue(); if (!isValidTagAttribute(attrName)) { - if (ComponentUtils.altSyntax(getStack()) && ComponentUtils.containsExpression(attrValue) && !lazyEvaluation()) { + if (ComponentUtils.containsExpression(attrValue) && !lazyEvaluation()) { String translated = TextParseUtil.translateVariables('%', attrValue, stack); dynamicAttributes.put(attrName, ObjectUtils.defaultIfNull(translated, attrValue)); } else { From 41e729205c9ba3e015d55b5f93f2863424d684ee Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 13 Jan 2022 10:32:53 +0100 Subject: [PATCH 09/33] WW-5117 Uses attribute translations in tests --- .../java/org/apache/struts2/views/jsp/ui/TextfieldTest.java | 2 +- .../resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java index 56d0eaa15..b2d4fdc5d 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java @@ -346,7 +346,7 @@ public class TextfieldTest extends AbstractUITagTest { tag.setName("myname"); tag.setValue("%{foo}"); tag.setSize("10"); - tag.setDynamicAttribute(null, "anotherAttr", "%{foo}"); + tag.setDynamicAttribute(null, "anotherAttr", "another_%{foo}"); tag.doStartTag(); tag.doEndTag(); diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt index 281847627..6dcdedba5 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt @@ -1,4 +1,4 @@ - + From 7ed77f5f0493d5d6f4db3479a4e9639c84e096e2 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 14 Jan 2022 09:22:21 +0100 Subject: [PATCH 10/33] WW-5117 Adds a new attribute to test the new behaviour --- .../java/org/apache/struts2/views/jsp/ui/TextfieldTest.java | 6 ++++-- .../org/apache/struts2/views/jsp/ui/Textfield-5.txt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java index b2d4fdc5d..f42fdbccf 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/TextfieldTest.java @@ -346,7 +346,8 @@ public class TextfieldTest extends AbstractUITagTest { tag.setName("myname"); tag.setValue("%{foo}"); tag.setSize("10"); - tag.setDynamicAttribute(null, "anotherAttr", "another_%{foo}"); + tag.setDynamicAttribute(null, "anotherAttr", "%{foo}"); + tag.setDynamicAttribute(null, "secondAttr", "second_%{foo}"); tag.doStartTag(); tag.doEndTag(); @@ -372,7 +373,8 @@ public class TextfieldTest extends AbstractUITagTest { tag.setName("myname"); tag.setValue("%{foo}"); tag.setSize("10"); - tag.setDynamicAttribute(null, "anotherAttr", "another_%{foo}"); + tag.setDynamicAttribute(null, "anotherAttr", "%{foo}"); + tag.setDynamicAttribute(null, "secondAttr", "second_%{foo}"); tag.doStartTag(); setComponentTagClearTagState(tag, true); // Ensure component tag state clearing is set true (to match tag). diff --git a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt index 6dcdedba5..5dc125c18 100644 --- a/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt +++ b/core/src/test/resources/org/apache/struts2/views/jsp/ui/Textfield-5.txt @@ -1,4 +1,4 @@ - + From 0a0573952f1a50bc65d35f0eecc17625c522865f Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 23 Jan 2022 10:38:12 +0100 Subject: [PATCH 11/33] WW-5112 Reduces logging in logic around missing resource key --- .../util/AbstractLocalizedTextProvider.java | 40 +++++++++---------- .../struts2/util/TextProviderHelper.java | 5 --- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java b/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java index fabb89c16..5685d5e30 100644 --- a/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java +++ b/core/src/main/java/com/opensymphony/xwork2/util/AbstractLocalizedTextProvider.java @@ -306,13 +306,13 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider { /** * A helper method for {@link ResourceBundle} bundle reload logic. - * - * Uses standard {@link ResourceBundle} methods to clear the bundle caches for the + * + * Uses standard {@link ResourceBundle} methods to clear the bundle caches for the * {@link ClassLoader} instances that this class is aware of at the time of the call. - * - * The clearCache() methods have been available since Java 1.6, so + * + * The clearCache() methods have been available since Java 1.6, so * it is anticipated the logic will work on any subsequent JVM versions. - * + * * @since 2.6 */ private void clearResourceBundleClassloaderCaches() { @@ -326,14 +326,14 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider { /** * "Hacky" helper method that attempts to clear the Tomcat ResourceEntry * {@link Map} using knowledge of the Tomcat source code. - * - * It relies on the {@link #TOMCAT_RESOURCE_ENTRIES_FIELD} field name, base class name + * + * It relies on the {@link #TOMCAT_RESOURCE_ENTRIES_FIELD} field name, base class name * {@link #TOMCAT_WEBAPP_CLASSLOADER_BASE}. and descendant class names {@link #TOMCAT_WEBAPP_CLASSLOADER}, * {@link #TOMCAT_PARALLEL_WEBAPP_CLASSLOADER}, to keep the values identified in the constants. * It appears to be valid for Tomcat versions 7-10 so far, but could become invalid at any time in the future * when the resource handling logic in Tomcat changes. - * - * Note: With Java 9+, calling this method may result in "Illegal reflective access" warnings. Be aware + * + * Note: With Java 9+, calling this method may result in "Illegal reflective access" warnings. Be aware * its logic may fail in a future version of Java that blocks the reflection calls needed for this method. */ private void clearTomcatCache() { @@ -367,10 +367,10 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider { /** * Helper method that is intended to clear a {@link Map} instance by name. - * + * * This method relies on reflection to perform its operations, and may be blocked in Java 9 and later, * depending on the accessibility of the field. - * + * * @param cl The {@link Class} of the obj parameter. * @param obj The {@link Object} from which the named field is to be extracted (may be null for a static field). * @param name The name of the field containing a {@link Map} reference. @@ -433,9 +433,9 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider { * Set the {@link #searchDefaultBundlesFirst} flag state. This flag may be used by descendant TextProvider * implementations to determine if default bundles should be searched for messages first (before the standard * flow of the {@link LocalizedTextProvider} implementation the descendant provides). - * + * * @param searchDefaultBundlesFirst provide {@link String} "true" or "false" to set the flag state accordingly. - * + * * @since 2.6 */ @Inject(value = StrutsConstants.STRUTS_I18N_SEARCH_DEFAULTBUNDLES_FIRST, required = false) @@ -490,7 +490,7 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider { } return bundle; } - + /** * Clears all the internal lists. * @@ -566,17 +566,17 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider { * against the default resource bundles. The default resource bundles are searched for a value using key first, then * alternateKey when the first search fails, then utilizing defaultMessage (which may be null) if both * key lookup operations fail. - * + * *

* A known use case is when a key indexes a collection (e.g. user.phone[0]) for which some specific keys may exist, but not all, * along with a general key (e.g. user.phone[*]). In such cases the specific key would be passed in the key parameter and the * general key would be passed in the alternateKey parameter. *

- * + * * @param key the initial key to search for a value within the default resource bundles. * @param alternateKey the alternate (fall-back) key to search for a value within the default resource bundles, if the initial key lookup fails. * @param locale the {@link Locale} to be used for the default resource bundle lookup. - * @param valueStack the {@link ValueStack} associated with the operation. + * @param valueStack the {@link ValueStack} associated with the operation. * @param args the argument array for parameterized messages (may be null). * @param defaultMessage the default message {@link String} to use if both key lookup operations fail. * @return the {@link GetDefaultMessageReturnArg} result containing the processed message lookup (by key first, then alternateKey if key's lookup fails). @@ -616,11 +616,7 @@ abstract class AbstractLocalizedTextProvider implements LocalizedTextProvider { MessageFormat mf = buildMessageFormat(message, locale); return formatWithNullDetection(mf, args); } catch (MissingResourceException e) { - if (devMode) { - LOG.warn("Missing key [{}] in bundle [{}]!", key, bundleName); - } else { - LOG.debug("Missing key [{}] in bundle [{}]!", key, bundleName); - } + LOG.debug("Missing key [{}] in bundle [{}]!", key, bundleName); return null; } } diff --git a/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java b/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java index 1fa411080..d7ad70681 100644 --- a/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java +++ b/core/src/main/java/org/apache/struts2/util/TextProviderHelper.java @@ -71,11 +71,6 @@ public class TextProviderHelper { } else { LOG.warn("Could not locate the message resource '{}' as there is no TextProvider in the ValueStack.", key); } - if (defaultMessage.equals(msg)) { - LOG.warn("The default value expression '{}' was evaluated and did not match a property. The literal value '{}' will be used.", defaultMessage, defaultMessage); - } else { - LOG.warn("The default value expression '{}' evaluated to '{}'", defaultMessage, msg); - } } } return msg; From 61e6d342bab6f4d0e0339300a79cb350747cc7cc Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 23 Jan 2022 10:45:14 +0100 Subject: [PATCH 12/33] WW-5022 Cleans up escapeHtmlBody flag with default value --- apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp | 4 ++-- .../src/main/webapp/WEB-INF/filedownload/index.jsp | 4 ++-- .../src/main/webapp/WEB-INF/hangman/hangmanNonAjax.ftl | 4 ++-- .../src/main/webapp/WEB-INF/person/new-person.ftl | 2 +- .../WEB-INF/tags/non-ui/actionPrefix/actionPrefix.ftl | 2 +- .../tags/non-ui/actionPrefix/actionPrefixExample.ftl | 8 ++++---- .../WEB-INF/tags/non-ui/actionPrefix/methodPrefix.ftl | 4 ++-- .../WEB-INF/tags/non-ui/actionPrefix/normalSubmit.ftl | 4 ++-- .../tags/non-ui/actionPrefix/redirectActionPrefix.ftl | 4 ++-- .../non-ui/iteratorTag/appendIteratorTagDemoResult.jsp | 2 +- .../non-ui/iteratorTag/iteratorGeneratorTagDemoResult.jsp | 2 +- .../non-ui/iteratorTag/mergeIteratorTagDemoResult.jsp | 2 +- .../non-ui/iteratorTag/subsetIteratorTagDemoResult.jsp | 2 +- apps/showcase/src/main/webapp/WEB-INF/token/example4.ftl | 2 +- .../main/java/org/apache/struts2/components/Submit.java | 2 +- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp b/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp index 39a3a03ea..0d09eb647 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp +++ b/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp @@ -113,7 +113,7 @@ - Download image file. + Download image file.
@@ -47,7 +47,7 @@
- Download ZIP file. + Download ZIP file.
diff --git a/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanNonAjax.ftl b/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanNonAjax.ftl index 046ab4bab..3c3251892 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanNonAjax.ftl +++ b/apps/showcase/src/main/webapp/WEB-INF/hangman/hangmanNonAjax.ftl @@ -125,7 +125,7 @@ <#else> " width="381" height="44" /> - <@s.a href="%{#startHref}" escapeHtmlBody="false"> + <@s.a href="%{#startHref}"> " width="250" height="43" /> <#else> @@ -139,7 +139,7 @@ <@s.a href="%{#url}" id="%{#currentCharacter}" - escapeHtmlBody="false" + > " width="36" border="0" /> diff --git a/apps/showcase/src/main/webapp/WEB-INF/person/new-person.ftl b/apps/showcase/src/main/webapp/WEB-INF/person/new-person.ftl index 6af4da446..07a66d4a6 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/person/new-person.ftl +++ b/apps/showcase/src/main/webapp/WEB-INF/person/new-person.ftl @@ -59,7 +59,7 @@
- <@s.submit value="Create person" cssClass="btn btn-primary" escapeHtmlBody="false"/> + <@s.submit value="Create person" cssClass="btn btn-primary"/>
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/actionPrefix.ftl b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/actionPrefix.ftl index 806883716..6e4432ea5 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/actionPrefix.ftl +++ b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/actionPrefix.ftl @@ -35,7 +35,7 @@

The text you've entered is ${text!''}

- <@s.a href="javascript:history.back();" cssClass="btn btn-info" escapeHtmlBody="false"> Back + <@s.a href="javascript:history.back();" cssClass="btn btn-info"> Back diff --git a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/actionPrefixExample.ftl b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/actionPrefixExample.ftl index 63312c786..98b0a9232 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/actionPrefixExample.ftl +++ b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/actionPrefixExample.ftl @@ -57,13 +57,13 @@ <@s.textfield label="Enter Some Text" name="text" /> - <@s.submit action="actionPrefix" value="%{'action prefix'}" cssClass="btn" escapeHtmlBody="false" /> + <@s.submit action="actionPrefix" value="%{'action prefix'}" cssClass="btn" /> - <@s.submit method="alternateMethod" value="%{'method prefix'}" cssClass="btn" escapeHtmlBody="false" /> + <@s.submit method="alternateMethod" value="%{'method prefix'}" cssClass="btn" /> - <@s.submit value="Normal Submit" cssClass="btn" escapeHtmlBody="false" /> + <@s.submit value="Normal Submit" cssClass="btn" /> - <@s.submit action="redirectActionPrefixAction" value="%{'redirectAction without prefix'}" cssClass="btn" escapeHtmlBody="false" /> + <@s.submit action="redirectActionPrefixAction" value="%{'redirectAction without prefix'}" cssClass="btn" /> diff --git a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/methodPrefix.ftl b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/methodPrefix.ftl index b94bf6d88..e2cf0ee56 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/methodPrefix.ftl +++ b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/methodPrefix.ftl @@ -32,10 +32,10 @@

You have come to this page because you used an method prefix.

- +

The text you've enter is ${text!''}

- <@s.a href="javascript:history.back();" cssClass="btn btn-info" escapeHtmlBody="false"> Back + <@s.a href="javascript:history.back();" cssClass="btn btn-info"> Back

diff --git a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/normalSubmit.ftl b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/normalSubmit.ftl index 3052ff173..7df58271d 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/normalSubmit.ftl +++ b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/normalSubmit.ftl @@ -32,10 +32,10 @@

You have come to this page because you did a normal submit.

- +

The text you've enter is %{text}

- <@s.a href="javascript:history.back();" cssClass="btn btn-info" escapeHtmlBody="false"> Back + <@s.a href="javascript:history.back();" cssClass="btn btn-info"> Back

diff --git a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/redirectActionPrefix.ftl b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/redirectActionPrefix.ftl index 602f6bee7..93fee964c 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/redirectActionPrefix.ftl +++ b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/actionPrefix/redirectActionPrefix.ftl @@ -32,13 +32,13 @@

You have come to this page because you used an 'redirect-action' prefix.

- +

Because this is a redirect-action, the text will be lost, due to a redirection implies a new request being issued from the client.

The text you've enter is ${text!''}

- <@s.a href="javascript:history.back();" cssClass="btn btn-info" escapeHtmlBody="false"> Back + <@s.a href="javascript:history.back();" cssClass="btn btn-info"> Back

diff --git a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/appendIteratorTagDemoResult.jsp b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/appendIteratorTagDemoResult.jsp index c95de872d..c2c7ff3dd 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/appendIteratorTagDemoResult.jsp +++ b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/appendIteratorTagDemoResult.jsp @@ -46,7 +46,7 @@
- Back To Input + Back To Input diff --git a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/iteratorGeneratorTagDemoResult.jsp b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/iteratorGeneratorTagDemoResult.jsp index fefb0933e..f4a31d897 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/iteratorGeneratorTagDemoResult.jsp +++ b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/iteratorGeneratorTagDemoResult.jsp @@ -41,7 +41,7 @@ - Back To Input + Back To Input diff --git a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/mergeIteratorTagDemoResult.jsp b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/mergeIteratorTagDemoResult.jsp index 3ae67a590..1798da445 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/mergeIteratorTagDemoResult.jsp +++ b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/mergeIteratorTagDemoResult.jsp @@ -45,7 +45,7 @@
- Back To Input + Back To Input diff --git a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/subsetIteratorTagDemoResult.jsp b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/subsetIteratorTagDemoResult.jsp index fc89d5e28..e704e577d 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/subsetIteratorTagDemoResult.jsp +++ b/apps/showcase/src/main/webapp/WEB-INF/tags/non-ui/iteratorTag/subsetIteratorTagDemoResult.jsp @@ -42,7 +42,7 @@ - Back To Input + Back To Input diff --git a/apps/showcase/src/main/webapp/WEB-INF/token/example4.ftl b/apps/showcase/src/main/webapp/WEB-INF/token/example4.ftl index e97fa0820..19dac0114 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/token/example4.ftl +++ b/apps/showcase/src/main/webapp/WEB-INF/token/example4.ftl @@ -51,7 +51,7 @@ <@s.form action="transfer4"> <@s.token/> <@s.textfield label="Amount" name="amount" required=true value="400"/> - <@s.submit value="Transfer money" cssClass="btn btn-primary" escapeHtmlBody="false"/> + <@s.submit value="Transfer money" cssClass="btn btn-primary"/> diff --git a/core/src/main/java/org/apache/struts2/components/Submit.java b/core/src/main/java/org/apache/struts2/components/Submit.java index 870e8ad0b..7d13d3b85 100644 --- a/core/src/main/java/org/apache/struts2/components/Submit.java +++ b/core/src/main/java/org/apache/struts2/components/Submit.java @@ -75,7 +75,7 @@ public class Submit extends FormButton { value = "Submit"; } - if (((key != null)) && (value == null)) { + if ((key != null) && (value == null)) { this.value = "%{getText('"+key +"')}"; } From e59abe4e344a8ce3ed2b1d460b623ccf303271aa Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 23 Jan 2022 10:58:14 +0100 Subject: [PATCH 13/33] WW-5164 Removes deprecated class --- .../metadata/ConversionDescription.java | 187 ------------------ .../xwork2/conversion/metadata/package.html | 21 -- 2 files changed, 208 deletions(-) delete mode 100644 core/src/main/java/com/opensymphony/xwork2/conversion/metadata/ConversionDescription.java delete mode 100644 core/src/main/java/com/opensymphony/xwork2/conversion/metadata/package.html diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/metadata/ConversionDescription.java b/core/src/main/java/com/opensymphony/xwork2/conversion/metadata/ConversionDescription.java deleted file mode 100644 index 74c6d6e6d..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/metadata/ConversionDescription.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.opensymphony.xwork2.conversion.metadata; - -import com.opensymphony.xwork2.conversion.annotations.ConversionRule; -import com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - -import java.io.PrintWriter; -import java.io.StringWriter; - -/** - * ConversionDescription - * - * @author Rainer Hermanns - * @version $Id$ - * - * @deprecated class will be removed - */ -@Deprecated -public class ConversionDescription { - - /** - * Jakarta commons-logging reference. - */ - protected static Logger log = null; - - - public static final String KEY_PREFIX = "Key_"; - public static final String ELEMENT_PREFIX = "Element_"; - public static final String KEY_PROPERTY_PREFIX = "KeyProperty_"; - public static final String DEPRECATED_ELEMENT_PREFIX = "Collection_"; - - /** - * Key used for type conversion of maps. - */ - String MAP_PREFIX = "Map_"; - - public String property; - public String typeConverter = ""; - public String rule = ""; - public String value = ""; - public String fullQualifiedClassName; - public String type = null; - - public ConversionDescription() { - log = LogManager.getLogger(this.getClass()); - } - - /** - * Creates an ConversionDescription with the specified property name. - * - * @param property property - */ - public ConversionDescription(String property) { - this.property = property; - log = LogManager.getLogger(this.getClass()); - } - - /** - *

- * Sets the property name to be inserted into the related conversion.properties file.
- * Note: Do not add COLLECTION_PREFIX or MAP_PREFIX keys to property names. - *

- * - * @param property The property to be converted. - */ - public void setProperty(String property) { - this.property = property; - } - - /** - * Sets the class name of the type converter to be used. - * - * @param typeConverter The class name of the type converter. - */ - public void setTypeConverter(String typeConverter) { - this.typeConverter = typeConverter; - } - - /** - * @param rule the rule prefix for COLLECTION_PREFIX or MAP_PREFIX key. Defaults to en empty String. - */ - public void setRule(String rule) { - if (rule != null && rule.length() > 0) { - if (rule.equals(ConversionRule.COLLECTION.toString())) { - this.rule = DefaultObjectTypeDeterminer.DEPRECATED_ELEMENT_PREFIX; - } else if (rule.equals(ConversionRule.ELEMENT.toString())) { - this.rule = DefaultObjectTypeDeterminer.ELEMENT_PREFIX; - } else if (rule.equals(ConversionRule.KEY.toString())) { - this.rule = DefaultObjectTypeDeterminer.KEY_PREFIX; - } else if (rule.equals(ConversionRule.KEY_PROPERTY.toString())) { - this.rule = DefaultObjectTypeDeterminer.KEY_PROPERTY_PREFIX; - } else if (rule.equals(ConversionRule.MAP.toString())) { - this.rule = MAP_PREFIX; - } - } - } - - - public void setType(String type) { - this.type = type; - } - - public String getType() { - return type; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - /** - * Returns the conversion description as property entry. - *

- * Example:
- * property.name = converter.className
- * Collection_property.name = converter.className
- * Map_property.name = converter.className - * KeyProperty_name = id - *

- * - * @return the conversion description as property entry. - */ - public String asProperty() { - StringWriter sw = new StringWriter(); - PrintWriter writer = null; - try { - writer = new PrintWriter(sw); - writer.print(rule); - writer.print(property); - writer.print("="); - if ( rule.startsWith(DefaultObjectTypeDeterminer.KEY_PROPERTY_PREFIX) && value != null && value.length() > 0 ) { - writer.print(value); - } else { - writer.print(typeConverter); - } - } finally { - if (writer != null) { - writer.flush(); - writer.close(); - } - } - - return sw.toString(); - - } - - /** - * Returns the fullQualifiedClassName attribute is used to create the special conversion.properties file name. - * - * @return full qualified class name - */ - public String getFullQualifiedClassName() { - return fullQualifiedClassName; - } - - /** - * The fullQualifiedClassName attribute is used to create the special conversion.properties file name. - * - * @param fullQualifiedClassName a full qualified class name - */ - public void setFullQualifiedClassName(String fullQualifiedClassName) { - this.fullQualifiedClassName = fullQualifiedClassName; - } -} diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/metadata/package.html b/core/src/main/java/com/opensymphony/xwork2/conversion/metadata/package.html deleted file mode 100644 index e48517d45..000000000 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/metadata/package.html +++ /dev/null @@ -1,21 +0,0 @@ - -Type conversion meta data classes. From 56595356d3addfa7ecf42a1610914a808bc40bf7 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 3 Apr 2021 17:32:38 +0200 Subject: [PATCH 14/33] WW-5115 Reduces logging for ignored DMI related params when DMI is disabled --- .../interceptor/ParametersInterceptor.java | 32 +++++++++++++++---- .../ParametersInterceptorTest.java | 27 ++++++++++++++++ 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java index a8f717636..69b717c6c 100644 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java +++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java @@ -40,6 +40,7 @@ import java.util.Collection; import java.util.Comparator; import java.util.Map; import java.util.TreeMap; +import java.util.regex.Pattern; /** * This interceptor sets all parameters on the value stack. @@ -50,8 +51,11 @@ public class ParametersInterceptor extends MethodFilterInterceptor { protected static final int PARAM_NAME_MAX_LENGTH = 100; + private static final Pattern DMI_IGNORED_PATTERN = Pattern.compile("^(action|method):.*", Pattern.CASE_INSENSITIVE); + private int paramNameMaxLength = PARAM_NAME_MAX_LENGTH; private boolean devMode = false; + private boolean dmiEnabled = false; protected boolean ordered = false; @@ -79,6 +83,11 @@ public class ParametersInterceptor extends MethodFilterInterceptor { this.acceptedPatterns = acceptedPatterns; } + @Inject(value = StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION, required = false) + protected void setDynamicMethodInvocation(String dmiEnabled) { + this.dmiEnabled = Boolean.parseBoolean(dmiEnabled); + } + /** * If the param name exceeds the configured maximum length it will not be * accepted. @@ -101,13 +110,10 @@ public class ParametersInterceptor extends MethodFilterInterceptor { /** * Compares based on number of '.' and '[' characters (fewer is higher) */ - static final Comparator rbCollator = new Comparator() { - public int compare(String s1, String s2) { - int l1 = countOGNLCharacters(s1); - int l2 = countOGNLCharacters(s2); - return l1 < l2 ? -1 : (l2 < l1 ? 1 : s1.compareTo(s2)); - } - + static final Comparator rbCollator = (s1, s2) -> { + int l1 = countOGNLCharacters(s1); + int l2 = countOGNLCharacters(s2); + return l1 < l2 ? -1 : (l2 < l1 ? 1 : s1.compareTo(s2)); }; @Override @@ -286,6 +292,10 @@ public class ParametersInterceptor extends MethodFilterInterceptor { } protected boolean acceptableName(String name) { + if (isIgnoredDMI(name)) { + LOG.trace("DMI is enabled, ignoring DMI method: {}", name); + return false; + } boolean accepted = isWithinLengthLimit(name) && !isExcluded(name) && isAccepted(name); if (devMode && accepted) { // notify only when in devMode LOG.debug("Parameter [{}] was accepted and will be appended to action!", name); @@ -293,6 +303,14 @@ public class ParametersInterceptor extends MethodFilterInterceptor { return accepted; } + private boolean isIgnoredDMI(String name) { + if (dmiEnabled) { + return DMI_IGNORED_PATTERN.matcher(name).matches(); + } else { + return false; + } + } + protected boolean isWithinLengthLimit(String name) { boolean matchLength = name.length() <= paramNameMaxLength; if (!matchLength) { diff --git a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java index 381f909d3..515b7cffe 100644 --- a/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java @@ -730,6 +730,33 @@ public class ParametersInterceptorTest extends XWorkTestCase { assertEquals(expected, actual); } + public void testDMIMethodsAreIgnored() throws Exception { + // given + ParametersInterceptor interceptor = createParametersInterceptor(); + final Map actual = injectValueStackFactory(interceptor); + ValueStack stack = injectValueStack(actual); + + final Map expected = new HashMap() { + { + put("ordinary.bean", "value"); + } + }; + + Map parameters = new HashMap() { + { + put("ordinary.bean", "value"); + put("action:", "myAction"); + put("method:", "doExecute"); + } + }; + + // when + interceptor.setParameters(new NoParametersAction(), stack, HttpParameters.create(parameters).build()); + + // then + assertEquals(expected, actual); + } + public void testBeanListSingleValue() throws Exception { Map params = new HashMap<>(); params.put("beanList.name", new String[]{"Superman"}); From 3a7aabdcbc177d12e17b8098f585dfc7aff32a0a Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 29 Jan 2022 17:26:55 +0100 Subject: [PATCH 15/33] WW-5166 Upgrades OGNL to version 3.3.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 52a8b2673..14d6ce410 100644 --- a/pom.xml +++ b/pom.xml @@ -112,7 +112,7 @@ 2.10.5 2.10.5.1 2.17.1 - 3.2.20 + 3.3.2 1.7.32 4.3.30.RELEASE 3.0.8 From f997d9b1ed876c8316c5b2b19760cdaf0b2bb6a6 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 29 Jan 2022 17:36:26 +0100 Subject: [PATCH 16/33] [maven-release-plugin] prepare release STRUTS_6_0_0_RC2 --- apps/pom.xml | 2 +- apps/rest-showcase/pom.xml | 4 ++-- apps/showcase/pom.xml | 2 +- assembly/pom.xml | 2 +- bom/pom.xml | 6 +++--- bundles/admin/pom.xml | 2 +- bundles/demo/pom.xml | 2 +- bundles/pom.xml | 2 +- core/pom.xml | 2 +- plugins/async/pom.xml | 2 +- plugins/bean-validation/pom.xml | 2 +- plugins/cdi/pom.xml | 2 +- plugins/config-browser/pom.xml | 2 +- plugins/convention/pom.xml | 2 +- plugins/dwr/pom.xml | 2 +- plugins/embeddedjsp/pom.xml | 2 +- plugins/gxp/pom.xml | 2 +- plugins/jasperreports/pom.xml | 2 +- plugins/javatemplates/pom.xml | 2 +- plugins/jfreechart/pom.xml | 2 +- plugins/json/pom.xml | 2 +- plugins/junit/pom.xml | 2 +- plugins/osgi/pom.xml | 2 +- plugins/oval/pom.xml | 2 +- plugins/pell-multipart/pom.xml | 2 +- plugins/plexus/pom.xml | 2 +- plugins/pom.xml | 2 +- plugins/portlet-mocks/pom.xml | 2 +- plugins/portlet-tiles/pom.xml | 2 +- plugins/portlet/pom.xml | 2 +- plugins/rest/pom.xml | 2 +- plugins/sitemesh/pom.xml | 2 +- plugins/spring/pom.xml | 2 +- plugins/testng/pom.xml | 2 +- plugins/tiles/pom.xml | 2 +- plugins/velocity/pom.xml | 2 +- pom.xml | 6 +++--- 37 files changed, 42 insertions(+), 42 deletions(-) diff --git a/apps/pom.xml b/apps/pom.xml index 791f306ba..d4120235e 100644 --- a/apps/pom.xml +++ b/apps/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-apps pom diff --git a/apps/rest-showcase/pom.xml b/apps/rest-showcase/pom.xml index 9264dcddd..aaa2dabda 100644 --- a/apps/rest-showcase/pom.xml +++ b/apps/rest-showcase/pom.xml @@ -24,12 +24,12 @@ org.apache.struts struts2-apps - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-rest-showcase war - 2.6-SNAPSHOT + 6.0.0-RC2 Struts 2 Rest Showcase Webapp Struts 2 Rest Showcase Example diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml index 78564ac36..2755b91ac 100644 --- a/apps/showcase/pom.xml +++ b/apps/showcase/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-apps - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-showcase diff --git a/assembly/pom.xml b/assembly/pom.xml index 4ad736216..4db62637d 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-assembly diff --git a/bom/pom.xml b/bom/pom.xml index 9d5be00f8..696595620 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -29,7 +29,7 @@ struts2-bom - 2.6-SNAPSHOT + 6.0.0-RC2 pom Struts 2 Bill of Materials @@ -44,7 +44,7 @@ - 2.6-SNAPSHOT + 6.0.0-RC2 true true @@ -175,7 +175,7 @@ - HEAD + STRUTS_6_0_0_RC2 scm:git:https://gitbox.apache.org/repos/asf/struts.git scm:git:https://gitbox.apache.org/repos/asf/struts.git https://github.com/apache/struts/ diff --git a/bundles/admin/pom.xml b/bundles/admin/pom.xml index c6cd0e652..2a229caa5 100644 --- a/bundles/admin/pom.xml +++ b/bundles/admin/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-osgi-bundles - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-osgi-admin-bundle diff --git a/bundles/demo/pom.xml b/bundles/demo/pom.xml index a2f639bd7..491ee259a 100644 --- a/bundles/demo/pom.xml +++ b/bundles/demo/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-osgi-bundles - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-osgi-demo-bundle diff --git a/bundles/pom.xml b/bundles/pom.xml index c6d4a9de8..ef3c5d5ad 100755 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-osgi-bundles diff --git a/core/pom.xml b/core/pom.xml index cd5677742..94a6aec99 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-core jar diff --git a/plugins/async/pom.xml b/plugins/async/pom.xml index b92e8ad60..bd32af3df 100644 --- a/plugins/async/pom.xml +++ b/plugins/async/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-async-plugin diff --git a/plugins/bean-validation/pom.xml b/plugins/bean-validation/pom.xml index fc616fa53..33144e36c 100644 --- a/plugins/bean-validation/pom.xml +++ b/plugins/bean-validation/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 4.0.0 diff --git a/plugins/cdi/pom.xml b/plugins/cdi/pom.xml index fefaa93c3..599b246fa 100644 --- a/plugins/cdi/pom.xml +++ b/plugins/cdi/pom.xml @@ -25,7 +25,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-cdi-plugin diff --git a/plugins/config-browser/pom.xml b/plugins/config-browser/pom.xml index 128600008..f973a5bff 100644 --- a/plugins/config-browser/pom.xml +++ b/plugins/config-browser/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-config-browser-plugin diff --git a/plugins/convention/pom.xml b/plugins/convention/pom.xml index f229e8bd9..09b064c94 100644 --- a/plugins/convention/pom.xml +++ b/plugins/convention/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-convention-plugin diff --git a/plugins/dwr/pom.xml b/plugins/dwr/pom.xml index c763c4633..f185440aa 100644 --- a/plugins/dwr/pom.xml +++ b/plugins/dwr/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-dwr-plugin diff --git a/plugins/embeddedjsp/pom.xml b/plugins/embeddedjsp/pom.xml index bf3ed66e3..0597bc6d5 100644 --- a/plugins/embeddedjsp/pom.xml +++ b/plugins/embeddedjsp/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-embeddedjsp-plugin diff --git a/plugins/gxp/pom.xml b/plugins/gxp/pom.xml index 0951f85f8..8caa6eeaa 100644 --- a/plugins/gxp/pom.xml +++ b/plugins/gxp/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-gxp-plugin diff --git a/plugins/jasperreports/pom.xml b/plugins/jasperreports/pom.xml index 6e8632f74..2a862ec5d 100644 --- a/plugins/jasperreports/pom.xml +++ b/plugins/jasperreports/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-jasperreports-plugin diff --git a/plugins/javatemplates/pom.xml b/plugins/javatemplates/pom.xml index 71e9c4596..b4f34ac9f 100644 --- a/plugins/javatemplates/pom.xml +++ b/plugins/javatemplates/pom.xml @@ -25,7 +25,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-javatemplates-plugin diff --git a/plugins/jfreechart/pom.xml b/plugins/jfreechart/pom.xml index 0ee1990de..44e8ffce0 100644 --- a/plugins/jfreechart/pom.xml +++ b/plugins/jfreechart/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-jfreechart-plugin diff --git a/plugins/json/pom.xml b/plugins/json/pom.xml index a89b221a3..4fe5670a9 100644 --- a/plugins/json/pom.xml +++ b/plugins/json/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-json-plugin diff --git a/plugins/junit/pom.xml b/plugins/junit/pom.xml index b978c8dde..2c24fe386 100644 --- a/plugins/junit/pom.xml +++ b/plugins/junit/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-junit-plugin diff --git a/plugins/osgi/pom.xml b/plugins/osgi/pom.xml index d5b73c73b..12ef327cd 100644 --- a/plugins/osgi/pom.xml +++ b/plugins/osgi/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-osgi-plugin diff --git a/plugins/oval/pom.xml b/plugins/oval/pom.xml index 7270d60d8..de8523c8a 100644 --- a/plugins/oval/pom.xml +++ b/plugins/oval/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-oval-plugin diff --git a/plugins/pell-multipart/pom.xml b/plugins/pell-multipart/pom.xml index ed234cbf6..eaf122073 100644 --- a/plugins/pell-multipart/pom.xml +++ b/plugins/pell-multipart/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-pell-multipart-plugin diff --git a/plugins/plexus/pom.xml b/plugins/plexus/pom.xml index 09af5adb1..5055cb9a6 100644 --- a/plugins/plexus/pom.xml +++ b/plugins/plexus/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-plexus-plugin diff --git a/plugins/pom.xml b/plugins/pom.xml index b9f625463..886692b42 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-plugins diff --git a/plugins/portlet-mocks/pom.xml b/plugins/portlet-mocks/pom.xml index 6bfd8491f..5269567f1 100644 --- a/plugins/portlet-mocks/pom.xml +++ b/plugins/portlet-mocks/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-portlet-mocks-plugin diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml index 8fb4c1ddc..9bbffe3d4 100644 --- a/plugins/portlet-tiles/pom.xml +++ b/plugins/portlet-tiles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-portlet-tiles-plugin diff --git a/plugins/portlet/pom.xml b/plugins/portlet/pom.xml index 1866afd47..385ba479d 100644 --- a/plugins/portlet/pom.xml +++ b/plugins/portlet/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-portlet-plugin diff --git a/plugins/rest/pom.xml b/plugins/rest/pom.xml index a149de6b5..515bd4cf9 100644 --- a/plugins/rest/pom.xml +++ b/plugins/rest/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-rest-plugin diff --git a/plugins/sitemesh/pom.xml b/plugins/sitemesh/pom.xml index e2f75bfd8..82d1c3209 100644 --- a/plugins/sitemesh/pom.xml +++ b/plugins/sitemesh/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-sitemesh-plugin diff --git a/plugins/spring/pom.xml b/plugins/spring/pom.xml index 774271d41..f1adeddf1 100644 --- a/plugins/spring/pom.xml +++ b/plugins/spring/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-spring-plugin diff --git a/plugins/testng/pom.xml b/plugins/testng/pom.xml index 7a2106707..13915fb3e 100644 --- a/plugins/testng/pom.xml +++ b/plugins/testng/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-testng-plugin diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml index 2507ee7a6..cfe2307d9 100644 --- a/plugins/tiles/pom.xml +++ b/plugins/tiles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-tiles-plugin diff --git a/plugins/velocity/pom.xml b/plugins/velocity/pom.xml index 8da8e57a0..6a983c325 100644 --- a/plugins/velocity/pom.xml +++ b/plugins/velocity/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 2.6-SNAPSHOT + 6.0.0-RC2 struts2-velocity-plugin diff --git a/pom.xml b/pom.xml index 14d6ce410..992c35a29 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 4.0.0 struts2-parent - 2.6-SNAPSHOT + 6.0.0-RC2 pom Struts 2 http://struts.apache.org/ @@ -51,7 +51,7 @@ scm:git:https://gitbox.apache.org/repos/asf/struts.git scm:git:https://gitbox.apache.org/repos/asf/struts.git https://github.com/apache/struts/ - HEAD + STRUTS_6_0_0_RC2 @@ -104,7 +104,7 @@ UTF-8 - 2021-12-19T11:50:38Z + 2022-01-29T16:32:23Z 1.8 From 14c3a14c8fca0741f2c516fcb0ec551ffcf1888f Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 29 Jan 2022 17:36:34 +0100 Subject: [PATCH 17/33] [maven-release-plugin] prepare for next development iteration --- apps/pom.xml | 2 +- apps/rest-showcase/pom.xml | 4 ++-- apps/showcase/pom.xml | 2 +- assembly/pom.xml | 2 +- bom/pom.xml | 6 +++--- bundles/admin/pom.xml | 2 +- bundles/demo/pom.xml | 2 +- bundles/pom.xml | 2 +- core/pom.xml | 2 +- plugins/async/pom.xml | 2 +- plugins/bean-validation/pom.xml | 2 +- plugins/cdi/pom.xml | 2 +- plugins/config-browser/pom.xml | 2 +- plugins/convention/pom.xml | 2 +- plugins/dwr/pom.xml | 2 +- plugins/embeddedjsp/pom.xml | 2 +- plugins/gxp/pom.xml | 2 +- plugins/jasperreports/pom.xml | 2 +- plugins/javatemplates/pom.xml | 2 +- plugins/jfreechart/pom.xml | 2 +- plugins/json/pom.xml | 2 +- plugins/junit/pom.xml | 2 +- plugins/osgi/pom.xml | 2 +- plugins/oval/pom.xml | 2 +- plugins/pell-multipart/pom.xml | 2 +- plugins/plexus/pom.xml | 2 +- plugins/pom.xml | 2 +- plugins/portlet-mocks/pom.xml | 2 +- plugins/portlet-tiles/pom.xml | 2 +- plugins/portlet/pom.xml | 2 +- plugins/rest/pom.xml | 2 +- plugins/sitemesh/pom.xml | 2 +- plugins/spring/pom.xml | 2 +- plugins/testng/pom.xml | 2 +- plugins/tiles/pom.xml | 2 +- plugins/velocity/pom.xml | 2 +- pom.xml | 6 +++--- 37 files changed, 42 insertions(+), 42 deletions(-) diff --git a/apps/pom.xml b/apps/pom.xml index d4120235e..54e3b841a 100644 --- a/apps/pom.xml +++ b/apps/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-apps pom diff --git a/apps/rest-showcase/pom.xml b/apps/rest-showcase/pom.xml index aaa2dabda..56533ec53 100644 --- a/apps/rest-showcase/pom.xml +++ b/apps/rest-showcase/pom.xml @@ -24,12 +24,12 @@ org.apache.struts struts2-apps - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-rest-showcase war - 6.0.0-RC2 + 6.0.0-SNAPSHOT Struts 2 Rest Showcase Webapp Struts 2 Rest Showcase Example diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml index 2755b91ac..9ce5d0b6c 100644 --- a/apps/showcase/pom.xml +++ b/apps/showcase/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-apps - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-showcase diff --git a/assembly/pom.xml b/assembly/pom.xml index 4db62637d..5abd8547c 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-assembly diff --git a/bom/pom.xml b/bom/pom.xml index 696595620..021a767b2 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -29,7 +29,7 @@ struts2-bom - 6.0.0-RC2 + 6.0.0-SNAPSHOT pom Struts 2 Bill of Materials @@ -44,7 +44,7 @@ - 6.0.0-RC2 + 6.0.0-SNAPSHOT true true @@ -175,7 +175,7 @@ - STRUTS_6_0_0_RC2 + HEAD scm:git:https://gitbox.apache.org/repos/asf/struts.git scm:git:https://gitbox.apache.org/repos/asf/struts.git https://github.com/apache/struts/ diff --git a/bundles/admin/pom.xml b/bundles/admin/pom.xml index 2a229caa5..4f5ce6cc2 100644 --- a/bundles/admin/pom.xml +++ b/bundles/admin/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-osgi-bundles - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-osgi-admin-bundle diff --git a/bundles/demo/pom.xml b/bundles/demo/pom.xml index 491ee259a..df1cd3231 100644 --- a/bundles/demo/pom.xml +++ b/bundles/demo/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-osgi-bundles - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-osgi-demo-bundle diff --git a/bundles/pom.xml b/bundles/pom.xml index ef3c5d5ad..606f2358f 100755 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-osgi-bundles diff --git a/core/pom.xml b/core/pom.xml index 94a6aec99..4ae6fa027 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-core jar diff --git a/plugins/async/pom.xml b/plugins/async/pom.xml index bd32af3df..8512e1986 100644 --- a/plugins/async/pom.xml +++ b/plugins/async/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-async-plugin diff --git a/plugins/bean-validation/pom.xml b/plugins/bean-validation/pom.xml index 33144e36c..b59367509 100644 --- a/plugins/bean-validation/pom.xml +++ b/plugins/bean-validation/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT 4.0.0 diff --git a/plugins/cdi/pom.xml b/plugins/cdi/pom.xml index 599b246fa..7dde20b68 100644 --- a/plugins/cdi/pom.xml +++ b/plugins/cdi/pom.xml @@ -25,7 +25,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-cdi-plugin diff --git a/plugins/config-browser/pom.xml b/plugins/config-browser/pom.xml index f973a5bff..e4e609bdf 100644 --- a/plugins/config-browser/pom.xml +++ b/plugins/config-browser/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-config-browser-plugin diff --git a/plugins/convention/pom.xml b/plugins/convention/pom.xml index 09b064c94..6bde5d2fa 100644 --- a/plugins/convention/pom.xml +++ b/plugins/convention/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-convention-plugin diff --git a/plugins/dwr/pom.xml b/plugins/dwr/pom.xml index f185440aa..9426ed66b 100644 --- a/plugins/dwr/pom.xml +++ b/plugins/dwr/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-dwr-plugin diff --git a/plugins/embeddedjsp/pom.xml b/plugins/embeddedjsp/pom.xml index 0597bc6d5..f8c56b547 100644 --- a/plugins/embeddedjsp/pom.xml +++ b/plugins/embeddedjsp/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-embeddedjsp-plugin diff --git a/plugins/gxp/pom.xml b/plugins/gxp/pom.xml index 8caa6eeaa..42908e4f3 100644 --- a/plugins/gxp/pom.xml +++ b/plugins/gxp/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-gxp-plugin diff --git a/plugins/jasperreports/pom.xml b/plugins/jasperreports/pom.xml index 2a862ec5d..eb0eb0808 100644 --- a/plugins/jasperreports/pom.xml +++ b/plugins/jasperreports/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-jasperreports-plugin diff --git a/plugins/javatemplates/pom.xml b/plugins/javatemplates/pom.xml index b4f34ac9f..a66f5514f 100644 --- a/plugins/javatemplates/pom.xml +++ b/plugins/javatemplates/pom.xml @@ -25,7 +25,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-javatemplates-plugin diff --git a/plugins/jfreechart/pom.xml b/plugins/jfreechart/pom.xml index 44e8ffce0..30681863f 100644 --- a/plugins/jfreechart/pom.xml +++ b/plugins/jfreechart/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-jfreechart-plugin diff --git a/plugins/json/pom.xml b/plugins/json/pom.xml index 4fe5670a9..4f9004cc5 100644 --- a/plugins/json/pom.xml +++ b/plugins/json/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-json-plugin diff --git a/plugins/junit/pom.xml b/plugins/junit/pom.xml index 2c24fe386..4a7e51369 100644 --- a/plugins/junit/pom.xml +++ b/plugins/junit/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-junit-plugin diff --git a/plugins/osgi/pom.xml b/plugins/osgi/pom.xml index 12ef327cd..dfdc0557f 100644 --- a/plugins/osgi/pom.xml +++ b/plugins/osgi/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-osgi-plugin diff --git a/plugins/oval/pom.xml b/plugins/oval/pom.xml index de8523c8a..f27298471 100644 --- a/plugins/oval/pom.xml +++ b/plugins/oval/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-oval-plugin diff --git a/plugins/pell-multipart/pom.xml b/plugins/pell-multipart/pom.xml index eaf122073..5de775f10 100644 --- a/plugins/pell-multipart/pom.xml +++ b/plugins/pell-multipart/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-pell-multipart-plugin diff --git a/plugins/plexus/pom.xml b/plugins/plexus/pom.xml index 5055cb9a6..7b9e9cd87 100644 --- a/plugins/plexus/pom.xml +++ b/plugins/plexus/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-plexus-plugin diff --git a/plugins/pom.xml b/plugins/pom.xml index 886692b42..4150947c4 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-plugins diff --git a/plugins/portlet-mocks/pom.xml b/plugins/portlet-mocks/pom.xml index 5269567f1..e4bf15a00 100644 --- a/plugins/portlet-mocks/pom.xml +++ b/plugins/portlet-mocks/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-portlet-mocks-plugin diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml index 9bbffe3d4..4a77faa82 100644 --- a/plugins/portlet-tiles/pom.xml +++ b/plugins/portlet-tiles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-portlet-tiles-plugin diff --git a/plugins/portlet/pom.xml b/plugins/portlet/pom.xml index 385ba479d..da4bc9bf0 100644 --- a/plugins/portlet/pom.xml +++ b/plugins/portlet/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-portlet-plugin diff --git a/plugins/rest/pom.xml b/plugins/rest/pom.xml index 515bd4cf9..73efaff36 100644 --- a/plugins/rest/pom.xml +++ b/plugins/rest/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-rest-plugin diff --git a/plugins/sitemesh/pom.xml b/plugins/sitemesh/pom.xml index 82d1c3209..af6ce18e6 100644 --- a/plugins/sitemesh/pom.xml +++ b/plugins/sitemesh/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-sitemesh-plugin diff --git a/plugins/spring/pom.xml b/plugins/spring/pom.xml index f1adeddf1..087c3b398 100644 --- a/plugins/spring/pom.xml +++ b/plugins/spring/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-spring-plugin diff --git a/plugins/testng/pom.xml b/plugins/testng/pom.xml index 13915fb3e..78aad4319 100644 --- a/plugins/testng/pom.xml +++ b/plugins/testng/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-testng-plugin diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml index cfe2307d9..7bfeef7ea 100644 --- a/plugins/tiles/pom.xml +++ b/plugins/tiles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-tiles-plugin diff --git a/plugins/velocity/pom.xml b/plugins/velocity/pom.xml index 6a983c325..8a2c69a80 100644 --- a/plugins/velocity/pom.xml +++ b/plugins/velocity/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC2 + 6.0.0-SNAPSHOT struts2-velocity-plugin diff --git a/pom.xml b/pom.xml index 992c35a29..6462f7689 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 4.0.0 struts2-parent - 6.0.0-RC2 + 6.0.0-SNAPSHOT pom Struts 2 http://struts.apache.org/ @@ -51,7 +51,7 @@ scm:git:https://gitbox.apache.org/repos/asf/struts.git scm:git:https://gitbox.apache.org/repos/asf/struts.git https://github.com/apache/struts/ - STRUTS_6_0_0_RC2 + HEAD @@ -104,7 +104,7 @@ UTF-8 - 2022-01-29T16:32:23Z + 2022-01-29T16:36:34Z 1.8 From f0b24d17da4751666f12bc498c73c20d91e29558 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 6 Feb 2022 11:26:51 +0100 Subject: [PATCH 18/33] WW-5167 Upgrades Xstream to version 1.4.19 to address CVE-2021-43859 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6462f7689..8b0e7712a 100644 --- a/pom.xml +++ b/pom.xml @@ -1134,7 +1134,7 @@ com.thoughtworks.xstream xstream - 1.4.18 + 1.4.19 io.github.x-stream From 804e1546f149174f6e88d69b77bd3fa9e8b9a76d Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 6 Feb 2022 12:23:39 +0100 Subject: [PATCH 19/33] WW-5016 Adds support for LocalDate and adjusts tests to use the new Java 8 API --- .../org/apache/struts2/components/Date.java | 44 ++-- .../struts2/views/jsp/ui/DateTagTest.java | 228 +++++++++++------- 2 files changed, 165 insertions(+), 107 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/Date.java b/core/src/main/java/org/apache/struts2/components/Date.java index 5f65d9c7b..ec9bb1997 100644 --- a/core/src/main/java/org/apache/struts2/components/Date.java +++ b/core/src/main/java/org/apache/struts2/components/Date.java @@ -29,6 +29,7 @@ import org.apache.struts2.views.annotations.StrutsTagAttribute; import java.io.IOException; import java.io.Writer; import java.time.Instant; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -40,7 +41,7 @@ import java.util.List; /** * - * + *

* Format Date object in different ways. *

* The date tag will allow you to format a Date in a quick and easy way. @@ -59,6 +60,12 @@ import java.util.List; *

* *

+ * Note: Since Struts 2.6 a new Java 8 API has been used to format the Date, it's based on + * DateTimeFormatter + * which uses a bit different patterns. + *

+ * + *

* Configurable attributes are: *

* @@ -130,8 +137,8 @@ import java.util.List; * if one is not found DateFormat.MEDIUM format will be used * * - * - * + *

+ *

* * *

Examples

@@ -145,9 +152,8 @@ import java.util.List; * * * Date - * */ -@StrutsTag(name="date", tldBodyContent="empty", tldTagClass="org.apache.struts2.views.jsp.DateTag", description="Render a formatted date.") +@StrutsTag(name = "date", tldBodyContent = "empty", tldTagClass = "org.apache.struts2.views.jsp.DateTag", description = "Render a formatted date.") public class Date extends ContextBean { private static final Logger LOG = LogManager.getLogger(Date.class); @@ -292,6 +298,8 @@ public class Date extends ContextBean { date = Instant.ofEpochMilli((long) dateObject).atZone(tz); } else if (dateObject instanceof LocalDateTime) { date = ((LocalDateTime) dateObject).atZone(tz); + } else if (dateObject instanceof LocalDate) { + date = ((LocalDate) dateObject).atStartOfDay(tz); } else if (dateObject instanceof Instant) { date = ((Instant) dateObject).atZone(tz); } else { @@ -300,18 +308,18 @@ public class Date extends ContextBean { String developerNotification = ""; if (tp != null) { developerNotification = findProviderInStack().getText( - "devmode.notification", - "Developer Notification:\n{0}", - new String[]{ - "Expression [" + name + "] passed to tag which was evaluated to [" + dateObject + "](" - + (dateObject != null ? dateObject.getClass() : "null") + ") isn't supported!" - } + "devmode.notification", + "Developer Notification:\n{0}", + new String[]{ + "Expression [" + name + "] passed to tag which was evaluated to [" + dateObject + "](" + + (dateObject != null ? dateObject.getClass() : "null") + ") isn't supported!" + } ); } LOG.warn(developerNotification); } else { LOG.debug("Expression [{}] passed to tag which was evaluated to [{}]({}) isn't supported!", - name, dateObject, (dateObject != null ? dateObject.getClass() : "null")); + name, dateObject, (dateObject != null ? dateObject.getClass() : "null")); } } @@ -338,11 +346,11 @@ public class Date extends ContextBean { // returned string is the same as input = // DATETAG_PROPERTY if (globalFormat != null - && !DATETAG_PROPERTY.equals(globalFormat)) { + && !DATETAG_PROPERTY.equals(globalFormat)) { dtf = DateTimeFormatter.ofPattern(globalFormat, ActionContext.getContext().getLocale()); } else { dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) - .withLocale(ActionContext.getContext().getLocale()); + .withLocale(ActionContext.getContext().getLocale()); } } else { dtf = DateTimeFormatter.ofPattern(format, ActionContext.getContext().getLocale()); @@ -378,17 +386,17 @@ public class Date extends ContextBean { return tz; } - @StrutsTagAttribute(description="Date or DateTime format pattern", rtexprvalue=false) + @StrutsTagAttribute(description = "Date or DateTime format pattern") public void setFormat(String format) { this.format = format; } - @StrutsTagAttribute(description="Whether to print out the date nicely", type="Boolean", defaultValue="false") + @StrutsTagAttribute(description = "Whether to print out the date nicely", type = "Boolean", defaultValue = "false") public void setNice(boolean nice) { this.nice = nice; } - @StrutsTagAttribute(description = "The specific timezone in which to format the date", required = false) + @StrutsTagAttribute(description = "The specific timezone in which to format the date") public void setTimezone(String timezone) { this.timezone = timezone; } @@ -400,7 +408,7 @@ public class Date extends ContextBean { return name; } - @StrutsTagAttribute(description="The date value to format", required=true) + @StrutsTagAttribute(description = "The date value to format", required = true) public void setName(String name) { this.name = name; } diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/DateTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/DateTagTest.java index 6f6e31ecc..05e267e05 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/DateTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/DateTagTest.java @@ -19,35 +19,33 @@ package org.apache.struts2.views.jsp.ui; import com.opensymphony.xwork2.ActionContext; - import org.apache.struts2.TestAction; +import org.apache.struts2.components.Component; +import org.apache.struts2.components.DateTextField; import org.apache.struts2.views.jsp.AbstractTagTest; import org.apache.struts2.views.jsp.DateTag; +import javax.servlet.jsp.JspException; import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.time.Instant; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; -import java.util.TimeZone; -import org.apache.struts2.components.Component; -import org.apache.struts2.components.DateTextField; /** * Unit test for {@link org.apache.struts2.components.Date}. - * */ public class DateTagTest extends AbstractTagTest { private DateTag tag; - public void testCustomFormat() throws Exception { + public void testCustomFormatForDateTime() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = new Date(); - String formatted = new SimpleDateFormat(format).format(now); + LocalDateTime now = LocalDateTime.now(); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); tag.setName("myDate"); @@ -62,13 +60,55 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); + } + + public void testCustomFormatForLong() throws Exception { + String format = "yyyy/MM/dd"; + long now = new Date().getTime(); + String formatted = DateTimeFormatter.ofPattern(format).format(Instant.ofEpochMilli(now).atZone(ZoneId.systemDefault())); + context.put("myDate", now); + + tag.setName("myDate"); + tag.setNice(false); + tag.setFormat(format); + tag.doStartTag(); + tag.doEndTag(); + assertEquals(formatted, writer.toString()); + + // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag(). + DateTag freshTag = new DateTag(); + freshTag.setPageContext(pageContext); + assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", + strutsBodyTagsAreReflectionEqual(tag, freshTag)); + } + + public void testCustomFormatForDate() throws Exception { + String format = "yyyy/MM/dd"; + LocalDate now = LocalDate.now(); + String formatted = DateTimeFormatter.ofPattern(format).format(now); + context.put("myDate", now); + + tag.setName("myDate"); + tag.setNice(false); + tag.setFormat(format); + tag.doStartTag(); + tag.doEndTag(); + assertEquals(formatted, writer.toString()); + + // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag(). + DateTag freshTag = new DateTag(); + freshTag.setPageContext(pageContext); + assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormat_clearTagStateSet() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = new Date(); - String formatted = new SimpleDateFormat(format).format(now); + LocalDateTime now = LocalDateTime.now(); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing. @@ -86,13 +126,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomGlobalFormatFormat() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = new Date(); - String formatted = new SimpleDateFormat(format).format(now); + LocalDateTime now = LocalDateTime.now(); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); ((TestAction) action).setText(org.apache.struts2.components.Date.DATETAG_PROPERTY, format); @@ -106,10 +146,8 @@ public class DateTagTest extends AbstractTagTest { public void testCustomFormatWithTimezone() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT+1")).getTime(); - SimpleDateFormat sdf = new SimpleDateFormat(format); - sdf.setTimeZone(TimeZone.getTimeZone("GMT+1")); - String formatted = sdf.format(now); + LocalDateTime now = LocalDateTime.now(ZoneId.of("GMT+1")); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); tag.setName("myDate"); @@ -126,15 +164,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatWithTimezone_clearTagStateSet() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT+1")).getTime(); - SimpleDateFormat sdf = new SimpleDateFormat(format); - sdf.setTimeZone(TimeZone.getTimeZone("GMT+1")); - String formatted = sdf.format(now); + LocalDateTime now = LocalDateTime.now(ZoneId.of("GMT+1")); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing. @@ -153,15 +189,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatWithTimezoneAsExpression() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT+2")).getTime(); - SimpleDateFormat sdf = new SimpleDateFormat(format); - sdf.setTimeZone(TimeZone.getTimeZone("GMT+2")); - String formatted = sdf.format(now); + LocalDateTime now = LocalDateTime.now(ZoneId.of("GMT+2")); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); context.put("myTimezone", "GMT+2"); @@ -178,15 +212,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatWithTimezoneAsExpression_clearTagStateSet() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = Calendar.getInstance(TimeZone.getTimeZone("GMT+2")).getTime(); - SimpleDateFormat sdf = new SimpleDateFormat(format); - sdf.setTimeZone(TimeZone.getTimeZone("GMT+2")); - String formatted = sdf.format(now); + LocalDateTime now = LocalDateTime.now(ZoneId.of("GMT+2")); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); context.put("myTimezone", "GMT+2"); @@ -206,13 +238,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatCalendar() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; Calendar calendar = Calendar.getInstance(); - String formatted = new SimpleDateFormat(format).format(calendar.getTime()); + String formatted = DateTimeFormatter.ofPattern(format).format(calendar.toInstant().atZone(ZoneId.systemDefault())); context.put("myDate", calendar); tag.setName("myDate"); @@ -227,13 +259,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatCalendar_clearTagStateSet() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; Calendar calendar = Calendar.getInstance(); - String formatted = new SimpleDateFormat(format).format(calendar.getTime()); + String formatted = DateTimeFormatter.ofPattern(format).format(calendar.toInstant().atZone(ZoneId.systemDefault())); context.put("myDate", calendar); tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing. @@ -251,13 +283,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatLong() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; Date date = new Date(); - String formatted = new SimpleDateFormat(format).format(date); + String formatted = DateTimeFormatter.ofPattern(format).format(date.toInstant().atZone(ZoneId.systemDefault())); // long context.put("myDate", date.getTime()); @@ -273,13 +305,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatLong_clearTagStateSet() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; Date date = new Date(); - String formatted = new SimpleDateFormat(format).format(date); + String formatted = DateTimeFormatter.ofPattern(format).format(date.toInstant().atZone(ZoneId.systemDefault())); // long context.put("myDate", date.getTime()); @@ -298,7 +330,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatLocalDateTime() throws Exception { @@ -332,7 +364,7 @@ public class DateTagTest extends AbstractTagTest { public void testDefaultFormat() throws Exception { Date now = new Date(); String formatted = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, - ActionContext.getContext().getLocale()).format(now); + ActionContext.getContext().getLocale()).format(now); context.put("myDate", now); tag.setName("myDate"); @@ -346,13 +378,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testDefaultFormat_clearTagStateSet() throws Exception { Date now = new Date(); String formatted = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, - ActionContext.getContext().getLocale()).format(now); + ActionContext.getContext().getLocale()).format(now); context.put("myDate", now); tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing. @@ -369,13 +401,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatAndComponent() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = new Date(); - String formatted = new SimpleDateFormat(format).format(now); + LocalDateTime now = LocalDateTime.now(); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); tag.setName("myDate"); @@ -388,7 +420,7 @@ public class DateTagTest extends AbstractTagTest { org.apache.struts2.components.Date component = (org.apache.struts2.components.Date) tag.getComponent(); assertEquals("myDate", component.getName()); assertEquals(format, component.getFormat()); - assertEquals(false, component.isNice()); + assertFalse(component.isNice()); tag.doEndTag(); @@ -399,13 +431,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testCustomFormatAndComponent_clearTagStateSet() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = new Date(); - String formatted = new SimpleDateFormat(format).format(now); + LocalDateTime now = LocalDateTime.now(); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing. @@ -420,7 +452,7 @@ public class DateTagTest extends AbstractTagTest { org.apache.struts2.components.Date component = (org.apache.struts2.components.Date) tag.getComponent(); assertEquals("myDate", component.getName()); assertEquals(format, component.getFormat()); - assertEquals(false, component.isNice()); + assertFalse(component.isNice()); tag.doEndTag(); @@ -432,13 +464,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testSetId() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = new Date(); - String formatted = new SimpleDateFormat(format).format(now); + LocalDateTime now = LocalDateTime.now(); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); tag.setName("myDate"); @@ -454,13 +486,13 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testSetId_clearTagStateSet() throws Exception { String format = "yyyy/MM/dd hh:mm:ss"; - Date now = new Date(); - String formatted = new SimpleDateFormat(format).format(now); + LocalDateTime now = LocalDateTime.now(); + String formatted = DateTimeFormatter.ofPattern(format).format(now); context.put("myDate", now); tag.setPerformClearTagStateForTagPoolingServers(true); // Explicitly request tag state clearing. @@ -479,7 +511,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureNiceHour() throws Exception { @@ -501,7 +533,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureNiceHour_clearTagStateSet() throws Exception { @@ -526,7 +558,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testPastNiceHour() throws Exception { @@ -548,7 +580,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testPastNiceHour_clearTagStateSet() throws Exception { @@ -573,7 +605,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureNiceHourMinSec() throws Exception { @@ -596,7 +628,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureNiceHourMinSec_clearTagStateSet() throws Exception { @@ -622,7 +654,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testPastNiceHourMin() throws Exception { @@ -645,7 +677,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testPastNiceHourMin_clearTagStateSet() throws Exception { @@ -671,7 +703,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureLessOneMin() throws Exception { @@ -693,7 +725,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureLessOneMin_clearTagStateSet() throws Exception { @@ -718,7 +750,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureLessOneHour() throws Exception { @@ -740,7 +772,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureLessOneHour_clearTagStateSet() throws Exception { @@ -765,7 +797,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureLessOneYear() throws Exception { @@ -787,7 +819,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureLessOneYear_clearTagStateSet() throws Exception { @@ -812,7 +844,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureTwoYears() throws Exception { @@ -838,7 +870,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testFutureTwoYears_clearTagStateSet() throws Exception { @@ -867,7 +899,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testNoDateObjectInContext() throws Exception { @@ -884,7 +916,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } public void testNoDateObjectInContext_clearTagStateSet() throws Exception { @@ -904,7 +936,7 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(tag, freshTag)); + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } /** @@ -912,10 +944,8 @@ public class DateTagTest extends AbstractTagTest { * since that tag does not have its own unit tests, and it also appears to be * a broken tag. The code coverage tests can be moved if the tag is fixed, or * removed if the tag is dropped. - * - * @throws Exception */ - public void testDateTextFieldTag_artificialCoverageTest() throws Exception { + public void testDateTextFieldTag_artificialCoverageTest() throws JspException { final String format = "yyyy/MM/dd hh:mm:ss"; DateTextFieldTag dateTextFieldTag = createDateTextFieldTag(); dateTextFieldTag.setFormat(format); @@ -939,20 +969,40 @@ public class DateTagTest extends AbstractTagTest { freshTag.setPageContext(pageContext); assertTrue("Tag state after doEndTag() and explicit tag state clearing is inequal to new Tag with pageContext/parent set. " + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", - strutsBodyTagsAreReflectionEqual(dateTextFieldTag, freshTag)); + strutsBodyTagsAreReflectionEqual(dateTextFieldTag, freshTag)); + } + + public void testNewJava8Format() throws Exception { + String format = "EEEE MMMM dd, hh:mm a"; + LocalDateTime now = LocalDateTime.now(); + String formatted = DateTimeFormatter.ofPattern(format, ActionContext.getContext().getLocale()).format(now); + context.put("myDate", now); + + tag.setName("myDate"); + tag.setNice(false); + tag.setFormat(format); + tag.doStartTag(); + tag.doEndTag(); + assertEquals(formatted, writer.toString()); + + // Basic sanity check of clearTagStateForTagPoolingServers() behaviour for Struts Tags after doEndTag(). + DateTag freshTag = new DateTag(); + freshTag.setPageContext(pageContext); + assertFalse("Tag state after doEndTag() under default tag clear state is equal to new Tag with pageContext/parent set. " + + "May indicate that clearTagStateForTagPoolingServers() calls are not working properly.", + strutsBodyTagsAreReflectionEqual(tag, freshTag)); } /** * Utility method to create a new {@link DateTextFieldTag} instance for code coverage tests. - * + *

* Note: There is no datetextfield.ftl template for the tag, so it does not appear that it can - * actually be used in practice. We can perform basic coverage tests from within this - * unit test class until the {@link DateTextFieldTag} is fixed or removed. - * + * actually be used in practice. We can perform basic coverage tests from within this + * unit test class until the {@link DateTextFieldTag} is fixed or removed. + * * @return a basic {@link DateTextFieldTag} instance - * @throws Exception */ - private DateTextFieldTag createDateTextFieldTag() throws Exception { + private DateTextFieldTag createDateTextFieldTag() { DateTextFieldTag tag = new DateTextFieldTag(); tag.setPageContext(pageContext); tag.setName("myDate"); From b1e9eae01ca9a33f597a952fd9944f01c68f0f66 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Wed, 9 Feb 2022 17:33:46 +0100 Subject: [PATCH 20/33] WW-5168 Support submit unchecked in Javatemplates and fixes logic for all FTL template --- .../apache/struts2/components/Checkbox.java | 3 +- .../views/java/simple/CheckboxHandler.java | 39 +++++++++++-------- .../views/java/simple/CheckboxTest.java | 19 +++++++++ 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/Checkbox.java b/core/src/main/java/org/apache/struts2/components/Checkbox.java index 591f425ac..dd853caba 100644 --- a/core/src/main/java/org/apache/struts2/components/Checkbox.java +++ b/core/src/main/java/org/apache/struts2/components/Checkbox.java @@ -75,7 +75,8 @@ public class Checkbox extends UIBean { } if (submitUnchecked != null) { - addParameter("submitUnchecked", findValue(submitUnchecked, Boolean.class)); + Object parsedValue = findValue(submitUnchecked, Boolean.class); + addParameter("submitUnchecked", parsedValue == null ? Boolean.valueOf(submitUnchecked) : parsedValue); } else { addParameter("submitUnchecked", false); } diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java index c712ddaeb..6f0e9651b 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java @@ -18,13 +18,14 @@ */ package org.apache.struts2.views.java.simple; -import org.apache.struts2.views.java.Attributes; -import org.apache.struts2.views.java.TagGenerator; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringEscapeUtils; +import org.apache.struts2.views.java.Attributes; +import org.apache.struts2.views.java.TagGenerator; import java.io.IOException; import java.util.Map; +import java.util.Objects; public class CheckboxHandler extends AbstractTagHandler implements TagGenerator { public void generate() throws IOException { @@ -35,29 +36,33 @@ public class CheckboxHandler extends AbstractTagHandler implements TagGenerator String id = (String) params.get("id"); String name = (String) params.get("name"); Object disabled = params.get("disabled"); + boolean submitUnchecked = Boolean.parseBoolean(Objects.toString(params.get("submitUnchecked"), "false")); attrs.add("type", "checkbox") - .add("name", name) - .add("value", fieldValue) - .addIfTrue("checked", params.get("nameValue")) - .addIfTrue("readonly", params.get("readonly")) - .addIfTrue("disabled", disabled) - .addIfExists("tabindex", params.get("tabindex")) - .addIfExists("id", id) - .addIfExists("class", params.get("cssClass")) - .addIfExists("style", params.get("cssStyle")) - .addIfExists("title", params.get("title")); + .add("name", name) + .add("value", fieldValue) + .addIfTrue("checked", params.get("nameValue")) + .addIfTrue("readonly", params.get("readonly")) + .addIfTrue("disabled", disabled) + .addIfExists("tabindex", params.get("tabindex")) + .addIfExists("id", id) + .addIfExists("class", params.get("cssClass")) + .addIfExists("style", params.get("cssStyle")) + .addIfExists("title", params.get("title")); start("input", attrs); end("input"); - //hidden input - attrs = new Attributes(); - attrs.add("type", "hidden") + if (!submitUnchecked) { + //hidden input + attrs = new Attributes(); + + attrs.add("type", "hidden") .add("id", "__checkbox_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(id))) .add("name", "__checkbox_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(name))) .add("value", "__checkbox_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(fieldValue))) .addIfTrue("disabled", disabled); - start("input", attrs); - end("input"); + start("input", attrs); + end("input"); + } } } diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java index 10a8e36c2..fa7d53a04 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java @@ -45,6 +45,25 @@ public class CheckboxTest extends AbstractCommonAttributesTest { assertEquals(expected, output); } + public void testRenderUncheckCheckbox() { + tag.setName("name_"); + tag.setDisabled("true"); + tag.setTabindex("1"); + tag.setId("id_"); + tag.setCssClass("class"); + tag.setCssStyle("style"); + tag.setTitle("title"); + tag.setFieldValue("xyz"); + tag.setSubmitUnchecked("true"); + + tag.evaluateParams(); + map.putAll(tag.getParameters()); + theme.renderTag(getTagName(), context); + String output = writer.getBuffer().toString(); + String expected = s(""); + assertEquals(expected, output); + } + public void testRenderCheckboxWithNameValue() { tag.setName("name_"); tag.setValue("%{someValue}"); From 1c3cab2e6f78f0479b4e776080693ec7faa149c6 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 10 Feb 2022 18:42:10 +0100 Subject: [PATCH 21/33] WW-5168 Fixes disabled attribute across all the Javatemplate tags --- .../apache/struts2/components/Component.java | 5 +- .../org/apache/struts2/components/UIBean.java | 12 ++-- .../apache/struts2/views/java/Attributes.java | 14 +++-- .../views/java/simple/AnchorHandler.java | 14 +++-- .../views/java/simple/LinkHandler.java | 6 +- .../views/java/simple/ResetHandler.java | 17 ++--- .../struts2/views/java/simple/AnchorTest.java | 2 +- .../views/java/simple/CheckboxTest.java | 5 +- .../struts2/views/java/simple/FileTest.java | 2 +- .../struts2/views/java/simple/HiddenTest.java | 2 +- .../struts2/views/java/simple/LinkTest.java | 63 ++++++++++++++----- .../views/java/simple/PasswordTest.java | 8 +-- .../struts2/views/java/simple/SelectTest.java | 2 +- .../struts2/views/java/simple/SubmitTest.java | 8 +-- .../views/java/simple/TextAreaTest.java | 4 +- .../views/java/simple/TextFieldTest.java | 2 +- 16 files changed, 103 insertions(+), 63 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/Component.java b/core/src/main/java/org/apache/struts2/components/Component.java index 2b0c58a3b..f45dac07d 100644 --- a/core/src/main/java/org/apache/struts2/components/Component.java +++ b/core/src/main/java/org/apache/struts2/components/Component.java @@ -384,9 +384,8 @@ public class Component { return expression; } } else { - expression = stripExpression(expression); - - return getStack().findValue(expression, toType, throwExceptionOnELFailure); + String strippedExpression = stripExpression(expression); + return getStack().findValue(strippedExpression, toType, throwExceptionOnELFailure); } } diff --git a/core/src/main/java/org/apache/struts2/components/UIBean.java b/core/src/main/java/org/apache/struts2/components/UIBean.java index 85b3d1bb9..4a4b5eb2b 100644 --- a/core/src/main/java/org/apache/struts2/components/UIBean.java +++ b/core/src/main/java/org/apache/struts2/components/UIBean.java @@ -702,11 +702,13 @@ public abstract class UIBean extends Component { } if (requiredLabel != null) { - addParameter("required", findValue(requiredLabel, Boolean.class)); + Object parsedValue = findValue(requiredLabel, Boolean.class); + addParameter("required", parsedValue == null ? Boolean.valueOf(requiredLabel) : parsedValue); } if (disabled != null) { - addParameter("disabled", findValue(disabled, Boolean.class)); + Object parsedValue = findValue(disabled, Boolean.class); + addParameter("disabled", parsedValue == null ? Boolean.valueOf(disabled) : parsedValue); } if (tabindex != null) { @@ -886,9 +888,9 @@ public abstract class UIBean extends Component { this.addParameter("tooltipDelay", findString(this.tooltipDelay)); if (this.javascriptTooltip != null) { - Boolean jsTooltips = (Boolean) findValue(this.javascriptTooltip, Boolean.class); + Object jsTooltips = findValue(this.javascriptTooltip, Boolean.class); //TODO use a Boolean model when tooltipConfig is dropped - this.addParameter("jsTooltipEnabled", jsTooltips.toString()); + this.addParameter("jsTooltipEnabled", jsTooltips == null ? this.javascriptTooltip : jsTooltips.toString()); if (form != null) form.addParameter("hasTooltip", jsTooltips); @@ -968,7 +970,7 @@ public abstract class UIBean extends Component { // 1] UI component's tooltipConfig attribute OR // 2] param tag value attribute - result = new LinkedHashMap<>((Map) tooltipConfigObj); + result = new LinkedHashMap((Map) tooltipConfigObj); } else if (tooltipConfigObj instanceof String) { // we get this if its configured using diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Attributes.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Attributes.java index 3a6050702..77a51e64c 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Attributes.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/Attributes.java @@ -28,7 +28,7 @@ import java.util.LinkedHashMap; */ public class Attributes extends LinkedHashMap { - private static final long serialVersionUID = 4103241472140545630L; + private static final long serialVersionUID = 4103241472140545630L; public Attributes add(String key, String value) { return add(key, value, true); @@ -74,15 +74,17 @@ public class Attributes extends LinkedHashMap { * @return this */ public Attributes addIfTrue(String attrName, Object paramValue) { - if (paramValue != null) { - if ((paramValue instanceof Boolean && ((Boolean) paramValue).booleanValue()) || - (Boolean.valueOf(paramValue.toString()).booleanValue())) { - put(attrName, attrName); - } + if (paramValue != null && isTrue(paramValue)) { + put(attrName, attrName); } return this; } + private boolean isTrue(Object paramValue) { + return (paramValue instanceof Boolean && (Boolean) paramValue) + || (Boolean.parseBoolean(paramValue.toString())); + } + /** * Add a key/value pair to the attributes, if the value is null, it will be set as an empty string. * Value is html encoded. diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java index 405088f0c..510abb691 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/AnchorHandler.java @@ -37,12 +37,14 @@ public class AnchorHandler extends AbstractTagHandler implements TagGenerator { Attributes attrs = new Attributes(); attrs.addIfExists("name", params.get("name")) - .addIfExists("id", params.get("id")) - .addIfExists("class", params.get("cssClass")) - .addIfExists("style", params.get("cssStyle")) - .addIfExists("href", params.get("href"), false) - .addIfExists("title", params.get("title")) - .addIfExists("tabindex", params.get("tabindex")); + .addIfExists("id", params.get("id")) + .addIfExists("class", params.get("cssClass")) + .addIfExists("style", params.get("cssStyle")) + .addIfExists("href", params.get("href"), false) + .addIfTrue("disabled", params.get("disabled")) + .addIfExists("title", params.get("title")) + .addIfExists("tabindex", params.get("tabindex")); + start("a", attrs); String body = (String) params.get("body"); Boolean escapeHtmlBody = (Boolean) params.get("escapeHtmlBody"); diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/LinkHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/LinkHandler.java index 55a7d353e..cf2daeec4 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/LinkHandler.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/LinkHandler.java @@ -40,9 +40,13 @@ public class LinkHandler extends AbstractTagHandler implements TagGenerator { .addIfExists("referrerpolicy", params.get("referrerpolicy")) .addIfExists("type", params.get("type")) .addIfExists("as", params.get("as")) - .addIfExists("disabled", params.get("disabled")) .addIfExists("title", params.get("title")); + // see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-disabled + if ("stylesheet".equals(params.get("rel"))) { + attrs.addIfTrue("disabled", params.get("disabled")); + } + start("link", attrs); end("link"); } diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ResetHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ResetHandler.java index c0eb9aa7a..fbb2dce09 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ResetHandler.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/ResetHandler.java @@ -18,9 +18,9 @@ */ package org.apache.struts2.views.java.simple; -import org.apache.struts2.views.java.TagGenerator; -import org.apache.struts2.views.java.Attributes; import org.apache.commons.lang3.StringUtils; +import org.apache.struts2.views.java.Attributes; +import org.apache.struts2.views.java.TagGenerator; import java.io.IOException; import java.util.Map; @@ -34,12 +34,13 @@ public class ResetHandler extends AbstractTagHandler implements TagGenerator { boolean isButton = "button".equals(params.get("type")); attrs.addDefaultToEmpty("name", params.get("name")) - .add("type", "reset") - .addIfExists("value", params.get("nameValue")) - .addIfExists("tabindex", params.get("tabindex")) - .addIfExists("id", params.get("id")) - .addIfExists("class", params.get("cssClass")) - .addIfExists("style", params.get("cssStyle")); + .add("type", "reset") + .addIfExists("value", params.get("nameValue")) + .addIfTrue("disabled", params.get("disabled")) + .addIfExists("tabindex", params.get("tabindex")) + .addIfExists("id", params.get("id")) + .addIfExists("class", params.get("cssClass")) + .addIfExists("style", params.get("cssStyle")); if (!isButton) attrs.addIfExists("title", params.get("title")); diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java index 58709a245..595713547 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/AnchorTest.java @@ -43,7 +43,7 @@ public class AnchorTest extends AbstractTest { theme.renderTag(getTagName(), context); theme.renderTag(getTagName() + "-close", context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java index fa7d53a04..8bb915d89 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java @@ -29,7 +29,7 @@ public class CheckboxTest extends AbstractCommonAttributesTest { public void testRenderCheckbox() { tag.setName("name_"); - tag.setDisabled("true"); + tag.setDisabled("false"); tag.setTabindex("1"); tag.setId("id_"); tag.setCssClass("class"); @@ -60,14 +60,13 @@ public class CheckboxTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } public void testRenderCheckboxWithNameValue() { tag.setName("name_"); tag.setValue("%{someValue}"); - tag.setDisabled("true"); tag.evaluateParams(); map.putAll(tag.getParameters()); diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/FileTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/FileTest.java index 3334fd3c7..0a455c28a 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/FileTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/FileTest.java @@ -43,7 +43,7 @@ public class FileTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/HiddenTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/HiddenTest.java index 48c5dc3ef..497ea88f1 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/HiddenTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/HiddenTest.java @@ -41,7 +41,7 @@ public class HiddenTest extends AbstractTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/LinkTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/LinkTest.java index 8e7b03935..873ede269 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/LinkTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/LinkTest.java @@ -31,7 +31,7 @@ public class LinkTest extends AbstractTest{ private static final String NONCE_VAL = "r4andom"; - public void testRenderScriptTag() { + public void testRenderLinkTag() { tag.setHref("testhref"); tag.setHreflang("test"); tag.setRel("module"); @@ -41,27 +41,60 @@ public class LinkTest extends AbstractTest{ tag.setCrossorigin("same-origin"); tag.setType("anonymous"); tag.setAs("test"); - tag.setDisabled("disabled_"); + tag.setDisabled("true"); tag.setTitle("test"); tag.evaluateParams(); map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); - String s = writer.getBuffer().toString(); + String output = writer.getBuffer().toString(); - assertTrue("Incorrect href attribute for link tag", s.contains("href=\"testhref\"")); - assertTrue("Incorrect hreflang attribute for link tag", s.contains("hreflang=\"test\"")); - assertTrue("Incorrect rel attribute for link tag", s.contains("rel=\"module\"")); - assertTrue("Incorrect media attribute for link tag", s.contains("media=\"foo\"")); - assertTrue("Incorrect referrerpolicy attribute for link tag", s.contains("referrerpolicy=\"test\"")); - assertTrue("Incorrect sizes attribute for link tag", s.contains("sizes=\"foo\"")); - assertTrue("Incorrect crossorigin attribute for link tag", s.contains("crossorigin=\"same-origin\"")); - assertTrue("Incorrect type attribute for link tag", s.contains("type=\"anonymous\"")); - assertTrue("Incorrect as attribute for link tag", s.contains("as=\"test\"")); - assertTrue("Non-existent disabled attribute for link tag", s.contains("disabled=\"disabled_\"")); - assertTrue("Incorrect title attribute for link tag", s.contains("title=\"test\"")); - assertTrue("Incorrect nonce attribute for link tag", s.contains("nonce=\"" + NONCE_VAL+"\"")); + assertTrue("Incorrect href attribute for link tag", output.contains(s("href='testhref'"))); + assertTrue("Incorrect hreflang attribute for link tag", output.contains(s("hreflang='test'"))); + assertTrue("Incorrect rel attribute for link tag", output.contains(s("rel='module'"))); + assertTrue("Incorrect media attribute for link tag", output.contains(s("media='foo'"))); + assertTrue("Incorrect referrerpolicy attribute for link tag", output.contains(s("referrerpolicy='test'"))); + assertTrue("Incorrect sizes attribute for link tag", output.contains(s("sizes='foo'"))); + assertTrue("Incorrect crossorigin attribute for link tag", output.contains(s("crossorigin='same-origin'"))); + assertTrue("Incorrect type attribute for link tag", output.contains(s("type='anonymous'"))); + assertTrue("Incorrect as attribute for link tag", output.contains(s("as='test'"))); + assertFalse("Non-existent disabled attribute for link tag", output.contains(s("disabled='disabled'"))); + assertTrue("Incorrect title attribute for link tag", output.contains(s("title='test'"))); + assertTrue("Incorrect nonce attribute for link tag", output.contains(s("nonce='" + NONCE_VAL+"'"))); } + + public void testRenderLinkTagAsStylesheet() { + tag.setHref("testhref"); + tag.setHreflang("test"); + tag.setRel("stylesheet"); + tag.setMedia("foo"); + tag.setReferrerpolicy("test"); + tag.setSizes("foo"); + tag.setCrossorigin("same-origin"); + tag.setType("anonymous"); + tag.setAs("test"); + tag.setDisabled("true"); + tag.setTitle("test"); + + tag.evaluateParams(); + map.putAll(tag.getParameters()); + theme.renderTag(getTagName(), context); + String output = writer.getBuffer().toString(); + + assertTrue("Incorrect href attribute for link tag", output.contains(s("href='testhref'"))); + assertTrue("Incorrect hreflang attribute for link tag", output.contains(s("hreflang='test'"))); + assertTrue("Incorrect rel attribute for link tag", output.contains(s("rel='stylesheet'"))); + assertTrue("Incorrect media attribute for link tag", output.contains(s("media='foo'"))); + assertTrue("Incorrect referrerpolicy attribute for link tag", output.contains(s("referrerpolicy='test'"))); + assertTrue("Incorrect sizes attribute for link tag", output.contains(s("sizes='foo'"))); + assertTrue("Incorrect crossorigin attribute for link tag", output.contains(s("crossorigin='same-origin'"))); + assertTrue("Incorrect type attribute for link tag", output.contains(s("type='anonymous'"))); + assertTrue("Incorrect as attribute for link tag", output.contains(s("as='test'"))); + assertTrue("Incorrect disabled attribute for link tag", output.contains(s("disabled='disabled'"))); + assertTrue("Incorrect title attribute for link tag", output.contains(s("title='test'"))); + assertTrue("Incorrect nonce attribute for link tag", output.contains(s("nonce='" + NONCE_VAL+"'"))); + } + @Override protected UIBean getUIBean() throws Exception { return tag; diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/PasswordTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/PasswordTest.java index da26301b4..84f48ce92 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/PasswordTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/PasswordTest.java @@ -24,11 +24,10 @@ import org.apache.struts2.components.Password; import org.apache.struts2.components.UIBean; public class PasswordTest extends AbstractCommonAttributesTest { + private Password tag; - private boolean showPassword; public void testRenderPassword() throws Exception { - this.showPassword = false; super.setUp(); this.tag = new Password(stack, request, response); @@ -47,12 +46,11 @@ public class PasswordTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } public void testRenderPasswordShowIt() throws Exception { - this.showPassword = true; super.setUp(); this.tag = new Password(stack, request, response); @@ -71,7 +69,7 @@ public class PasswordTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/SelectTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/SelectTest.java index bfe7e0360..28d601fb6 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/SelectTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/SelectTest.java @@ -45,7 +45,7 @@ public class SelectTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/SubmitTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/SubmitTest.java index 8609630a7..cbb7f6c5f 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/SubmitTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/SubmitTest.java @@ -47,7 +47,7 @@ public class SubmitTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName() + "-close", context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } @@ -69,7 +69,7 @@ public class SubmitTest extends AbstractCommonAttributesTest { theme.renderTag(getTagName(), context); theme.renderTag(getTagName() + "-close", context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } @@ -91,7 +91,7 @@ public class SubmitTest extends AbstractCommonAttributesTest { theme.renderTag(getTagName(), context); theme.renderTag(getTagName() + "-close", context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } @@ -112,7 +112,7 @@ public class SubmitTest extends AbstractCommonAttributesTest { theme.renderTag(getTagName(), context); theme.renderTag(getTagName() + "-close", context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/TextAreaTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/TextAreaTest.java index bae57795e..fb5d8e071 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/TextAreaTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/TextAreaTest.java @@ -44,7 +44,7 @@ public class TextAreaTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } @@ -63,7 +63,7 @@ public class TextAreaTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/TextFieldTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/TextFieldTest.java index 7371fa1b4..5973ea5ff 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/TextFieldTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/TextFieldTest.java @@ -44,7 +44,7 @@ public class TextFieldTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } From d454384a4b5772e0c1b76e46922c5ed9c4548d3d Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 13 Feb 2022 10:00:20 +0100 Subject: [PATCH 22/33] WW-5168 Reverts condition in if statement --- .../org/apache/struts2/views/java/simple/CheckboxHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java index 6f0e9651b..6fe4a8bb7 100644 --- a/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java +++ b/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java @@ -52,7 +52,7 @@ public class CheckboxHandler extends AbstractTagHandler implements TagGenerator start("input", attrs); end("input"); - if (!submitUnchecked) { + if (submitUnchecked) { //hidden input attrs = new Attributes(); From fe7959e5d879fdefb1eeea4794d1bbddb7b6b5ef Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 13 Feb 2022 10:19:01 +0100 Subject: [PATCH 23/33] WW-5168 Adjusts tests to flipped if condition --- .../org/apache/struts2/views/java/simple/CheckboxTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java index 8bb915d89..d7d56ec0a 100644 --- a/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java +++ b/plugins/javatemplates/src/test/java/org/apache/struts2/views/java/simple/CheckboxTest.java @@ -41,7 +41,7 @@ public class CheckboxTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } @@ -60,7 +60,7 @@ public class CheckboxTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } @@ -72,7 +72,7 @@ public class CheckboxTest extends AbstractCommonAttributesTest { map.putAll(tag.getParameters()); theme.renderTag(getTagName(), context); String output = writer.getBuffer().toString(); - String expected = s(""); + String expected = s(""); assertEquals(expected, output); } From 38c63334a4748838db1be82f7fb1f31fe6944a36 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 20 Feb 2022 10:37:25 +0100 Subject: [PATCH 24/33] WW-4963 Adds missing references to the new versions --- .../interceptor/ServletConfigInterceptor.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java index 0ef0f3786..634240085 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java @@ -45,25 +45,23 @@ import com.opensymphony.xwork2.interceptor.AbstractInterceptor; *

* *
    - * *
  • {@link ServletContextAware}
  • - * + *
  • {@link org.apache.struts2.action.ServletContextAware}
  • *
  • {@link ServletRequestAware}
  • - * + *
  • {@link org.apache.struts2.action.ServletRequestAware}
  • *
  • {@link ServletResponseAware}
  • - * + *
  • {@link org.apache.struts2.action.ServletResponseAware}
  • *
  • {@link ParameterAware} - deprecated since 2.5.4, please use {@link HttpParametersAware}
  • - * *
  • {@link HttpParametersAware}
  • - * + *
  • {@link org.apache.struts2.action.ParametersAware}
  • *
  • {@link RequestAware}
  • - * + *
  • {@link org.apache.struts2.action.ServletRequestAware}
  • *
  • {@link SessionAware}
  • - * + *
  • {@link org.apache.struts2.action.SessionAware}
  • *
  • {@link ApplicationAware}
  • - * + *
  • {@link org.apache.struts2.action.ApplicationAware}
  • *
  • {@link PrincipalAware}
  • - * + *
  • {@link org.apache.struts2.action.PrincipalAware}
  • *
* * @@ -101,13 +99,19 @@ import com.opensymphony.xwork2.interceptor.AbstractInterceptor; * * * @see ServletContextAware + * @see org.apache.struts2.action.ServletContextAware * @see ServletRequestAware + * @see org.apache.struts2.action.ServletRequestAware * @see ServletResponseAware + * @see org.apache.struts2.action.ServletResponseAware * @see ParameterAware - * @see ParametersAware + * @see org.apache.struts2.action.ParametersAware * @see SessionAware + * @see org.apache.struts2.action.SessionAware * @see ApplicationAware + * @see org.apache.struts2.action.ApplicationAware * @see PrincipalAware + * @see org.apache.struts2.action.PrincipalAware */ public class ServletConfigInterceptor extends AbstractInterceptor implements StrutsStatics { @@ -159,7 +163,7 @@ public class ServletConfigInterceptor extends AbstractInterceptor implements Str if (action instanceof ApplicationAware) { ((ApplicationAware) action).setApplication(context.getApplication()); } - + if (action instanceof org.apache.struts2.action.ApplicationAware) { ((org.apache.struts2.action.ApplicationAware) action).withApplication(context.getApplication()); } @@ -167,7 +171,7 @@ public class ServletConfigInterceptor extends AbstractInterceptor implements Str if (action instanceof SessionAware) { ((SessionAware) action).setSession(context.getSession()); } - + if (action instanceof org.apache.struts2.action.SessionAware) { ((org.apache.struts2.action.SessionAware) action).withSession(context.getSession()); } @@ -179,7 +183,7 @@ public class ServletConfigInterceptor extends AbstractInterceptor implements Str if (action instanceof PrincipalAware) { HttpServletRequest request = context.getServletRequest(); if(request != null) { - // We are in servtlet environment, so principal information resides in HttpServletRequest + // We are in servlet environment, so principal information resides in HttpServletRequest ((PrincipalAware) action).setPrincipalProxy(new ServletPrincipalProxy(request)); } } From e3dff7691e72a30cf6ebcad1bbace48e56f56380 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 20 Feb 2022 13:29:46 +0100 Subject: [PATCH 25/33] WW-5016 Introduces different format adapters to allow use different APIs --- .../StrutsDefaultConfigurationProvider.java | 6 ++ .../org/apache/struts2/StrutsConstants.java | 3 + .../org/apache/struts2/components/Date.java | 78 ++++++++-------- .../components/date/DateFormatter.java | 33 +++++++ .../date/DateTimeFormatterAdapter.java | 47 ++++++++++ .../date/SimpleDateFormatAdapter.java | 48 ++++++++++ .../config/StrutsBeanSelectionProvider.java | 5 +- .../org/apache/struts2/default.properties | 6 ++ core/src/main/resources/struts-default.xml | 5 +- .../apache/struts2/components/DateTest.java | 90 +++++++++++++++++++ 10 files changed, 280 insertions(+), 41 deletions(-) create mode 100644 core/src/main/java/org/apache/struts2/components/date/DateFormatter.java create mode 100644 core/src/main/java/org/apache/struts2/components/date/DateTimeFormatterAdapter.java create mode 100644 core/src/main/java/org/apache/struts2/components/date/SimpleDateFormatAdapter.java create mode 100644 core/src/test/java/org/apache/struts2/components/DateTest.java diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java index 400674d2d..a5dcf99cb 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java @@ -56,6 +56,9 @@ import com.opensymphony.xwork2.conversion.impl.DateConverter; import com.opensymphony.xwork2.conversion.impl.DefaultConversionAnnotationProcessor; import com.opensymphony.xwork2.conversion.impl.DefaultConversionFileProcessor; import com.opensymphony.xwork2.security.NotExcludedAcceptedPatternsChecker; +import org.apache.struts2.components.date.DateFormatter; +import org.apache.struts2.components.date.DateTimeFormatterAdapter; +import org.apache.struts2.components.date.SimpleDateFormatAdapter; import org.apache.struts2.conversion.StrutsConversionPropertiesProcessor; import com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer; import org.apache.struts2.conversion.StrutsTypeConverterCreator; @@ -218,6 +221,9 @@ public class StrutsDefaultConfigurationProvider implements ConfigurationProvider , Scope.SINGLETON) .factory(ValueSubstitutor.class, EnvsValueSubstitutor.class, Scope.SINGLETON) + + .factory(DateFormatter.class, "simpleDateFormat", SimpleDateFormatAdapter.class, Scope.SINGLETON) + .factory(DateFormatter.class, "dateTimeFormatter", DateTimeFormatterAdapter.class, Scope.SINGLETON) ; props.setProperty(StrutsConstants.STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION, Boolean.FALSE.toString()); diff --git a/core/src/main/java/org/apache/struts2/StrutsConstants.java b/core/src/main/java/org/apache/struts2/StrutsConstants.java index 789b7c388..64ac93b04 100644 --- a/core/src/main/java/org/apache/struts2/StrutsConstants.java +++ b/core/src/main/java/org/apache/struts2/StrutsConstants.java @@ -18,6 +18,7 @@ */ package org.apache.struts2; +import org.apache.struts2.components.date.DateFormatter; import org.apache.struts2.dispatcher.mapper.CompositeActionMapper; /** @@ -384,4 +385,6 @@ public final class StrutsConstants { public static final String STRUTS_CHAINING_COPY_MESSAGES = "struts.chaining.copyMessages"; public static final String STRUTS_OBJECT_FACTORY_CLASSLOADER = "struts.objectFactory.classloader"; + /** See {@link org.apache.struts2.components.Date#setDateFormatter(DateFormatter)} */ + public static final String STRUTS_DATE_FORMATTER = "struts.date.formatter"; } diff --git a/core/src/main/java/org/apache/struts2/components/Date.java b/core/src/main/java/org/apache/struts2/components/Date.java index ec9bb1997..0560057b8 100644 --- a/core/src/main/java/org/apache/struts2/components/Date.java +++ b/core/src/main/java/org/apache/struts2/components/Date.java @@ -18,11 +18,13 @@ */ package org.apache.struts2.components; -import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.TextProvider; +import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.ValueStack; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.struts2.StrutsConstants; +import org.apache.struts2.components.date.DateFormatter; import org.apache.struts2.views.annotations.StrutsTag; import org.apache.struts2.views.annotations.StrutsTagAttribute; @@ -33,8 +35,6 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.format.FormatStyle; import java.util.ArrayList; import java.util.Calendar; import java.util.List; @@ -157,6 +157,7 @@ import java.util.List; public class Date extends ContextBean { private static final Logger LOG = LogManager.getLogger(Date.class); + /** * Property name to fall back when no format is specified */ @@ -208,17 +209,18 @@ public class Date extends ContextBean { private String timezone; + private DateFormatter dateFormatter; + public Date(ValueStack stack) { super(stack); } - private TextProvider findProviderInStack() { - for (Object o : getStack().getRoot()) { - if (o instanceof TextProvider) { - return (TextProvider) o; - } - } - return null; + /** + * An instance of {@link DateFormatter} + */ + @Inject + public void setDateFormatter(DateFormatter dateFormatter) { + this.dateFormatter = dateFormatter; } /** @@ -286,6 +288,8 @@ public class Date extends ContextBean { @Override public boolean end(Writer writer, String body) { + TextProvider textProvider = findProviderInStack(); + ZonedDateTime date = null; final ZoneId tz = getTimeZone(); // find the name on the valueStack @@ -304,10 +308,9 @@ public class Date extends ContextBean { date = ((Instant) dateObject).atZone(tz); } else { if (devMode) { - TextProvider tp = findProviderInStack(); String developerNotification = ""; - if (tp != null) { - developerNotification = findProviderInStack().getText( + if (textProvider != null) { + developerNotification = textProvider.getText( "devmode.notification", "Developer Notification:\n{0}", new String[]{ @@ -329,33 +332,11 @@ public class Date extends ContextBean { } String msg; if (date != null) { - TextProvider tp = findProviderInStack(); - if (tp != null) { + if (textProvider != null) { if (nice) { - msg = formatTime(tp, date); + msg = formatTime(textProvider, date); } else { - DateTimeFormatter dtf; - if (format == null) { - String globalFormat = null; - - // if the format is not specified, fall back using the - // defined property DATETAG_PROPERTY - globalFormat = tp.getText(DATETAG_PROPERTY); - - // if tp.getText can not find the property then the - // returned string is the same as input = - // DATETAG_PROPERTY - if (globalFormat != null - && !DATETAG_PROPERTY.equals(globalFormat)) { - dtf = DateTimeFormatter.ofPattern(globalFormat, ActionContext.getContext().getLocale()); - } else { - dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) - .withLocale(ActionContext.getContext().getLocale()); - } - } else { - dtf = DateTimeFormatter.ofPattern(format, ActionContext.getContext().getLocale()); - } - msg = dtf.format(date); + msg = formatDate(textProvider, date); } if (msg != null) { try { @@ -373,6 +354,18 @@ public class Date extends ContextBean { return super.end(writer, ""); } + private String formatDate(TextProvider textProvider, ZonedDateTime date) { + // if the format is not specified, fall back using the defined property DATETAG_PROPERTY + String globalFormat = textProvider.getText(Date.DATETAG_PROPERTY); + if (DATETAG_PROPERTY.equals(globalFormat)) { + // if tp.getText can not find the property then the + // returned string is the same as input = DATETAG_PROPERTY + globalFormat = null; + } + + return dateFormatter.format(date, format, globalFormat); + } + private ZoneId getTimeZone() { ZoneId tz = ZoneId.systemDefault(); if (timezone != null) { @@ -386,6 +379,15 @@ public class Date extends ContextBean { return tz; } + private TextProvider findProviderInStack() { + for (Object o : getStack().getRoot()) { + if (o instanceof TextProvider) { + return (TextProvider) o; + } + } + return null; + } + @StrutsTagAttribute(description = "Date or DateTime format pattern") public void setFormat(String format) { this.format = format; diff --git a/core/src/main/java/org/apache/struts2/components/date/DateFormatter.java b/core/src/main/java/org/apache/struts2/components/date/DateFormatter.java new file mode 100644 index 000000000..7ad276a25 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/components/date/DateFormatter.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.components.date; + +import java.time.temporal.TemporalAccessor; + +/** + * Allows defines a wrapper around different formatting APIs, like old SimpleDateFormat + * and new DateTimeFormatter introduced in Java 8 Date/Time API + * + * New instance will be injected using {@link org.apache.struts2.StrutsConstants#STRUTS_DATE_FORMATTER} + */ +public interface DateFormatter { + + String format(TemporalAccessor temporal, String format, String defaultFormat); + +} diff --git a/core/src/main/java/org/apache/struts2/components/date/DateTimeFormatterAdapter.java b/core/src/main/java/org/apache/struts2/components/date/DateTimeFormatterAdapter.java new file mode 100644 index 000000000..64bb4b165 --- /dev/null +++ b/core/src/main/java/org/apache/struts2/components/date/DateTimeFormatterAdapter.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.components.date; + +import com.opensymphony.xwork2.ActionContext; + +import java.time.format.DateTimeFormatter; +import java.time.format.FormatStyle; +import java.time.temporal.TemporalAccessor; +import java.util.Locale; + +public class DateTimeFormatterAdapter implements DateFormatter { + + @Override + public String format(TemporalAccessor temporal, String format, String defaultFormat) { + DateTimeFormatter dtf; + Locale locale = ActionContext.getContext().getLocale(); + if (format == null) { + if (defaultFormat != null) { + dtf = DateTimeFormatter.ofPattern(defaultFormat, locale); + } else { + dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) + .withLocale(locale); + } + } else { + dtf = DateTimeFormatter.ofPattern(format, locale); + } + return dtf.format(temporal); + } + +} diff --git a/core/src/main/java/org/apache/struts2/components/date/SimpleDateFormatAdapter.java b/core/src/main/java/org/apache/struts2/components/date/SimpleDateFormatAdapter.java new file mode 100644 index 000000000..e9f29f0be --- /dev/null +++ b/core/src/main/java/org/apache/struts2/components/date/SimpleDateFormatAdapter.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.components.date; + +import com.opensymphony.xwork2.ActionContext; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.temporal.TemporalAccessor; +import java.util.Date; +import java.util.Locale; + +public class SimpleDateFormatAdapter implements DateFormatter { + + @Override + public String format(TemporalAccessor temporal, String format, String defaultFormat) { + DateFormat df; + Locale locale = ActionContext.getContext().getLocale(); + if (format == null) { + if (defaultFormat != null) { + df = new SimpleDateFormat(defaultFormat, locale); + } else { + df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, locale); + } + } else { + df = new SimpleDateFormat(format, locale); + } + return df.format(new Date(Instant.from(temporal).toEpochMilli())); + } + +} diff --git a/core/src/main/java/org/apache/struts2/config/StrutsBeanSelectionProvider.java b/core/src/main/java/org/apache/struts2/config/StrutsBeanSelectionProvider.java index ade6aa0b0..69aa9258e 100644 --- a/core/src/main/java/org/apache/struts2/config/StrutsBeanSelectionProvider.java +++ b/core/src/main/java/org/apache/struts2/config/StrutsBeanSelectionProvider.java @@ -54,13 +54,12 @@ import com.opensymphony.xwork2.util.PatternMatcher; import com.opensymphony.xwork2.util.TextParser; import com.opensymphony.xwork2.util.ValueStackFactory; import com.opensymphony.xwork2.util.location.LocatableProperties; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; import com.opensymphony.xwork2.util.reflection.ReflectionContextFactory; import com.opensymphony.xwork2.util.reflection.ReflectionProvider; import com.opensymphony.xwork2.validator.ActionValidatorManager; import org.apache.struts2.StrutsConstants; import org.apache.struts2.components.UrlRenderer; +import org.apache.struts2.components.date.DateFormatter; import org.apache.struts2.dispatcher.DispatcherErrorHandler; import org.apache.struts2.dispatcher.StaticContentLoader; import org.apache.struts2.dispatcher.mapper.ActionMapper; @@ -422,6 +421,8 @@ public class StrutsBeanSelectionProvider extends AbstractBeanSelectionProvider { alias(NotExcludedAcceptedPatternsChecker.class, StrutsConstants.STRUTS_NOT_EXCLUDED_ACCEPTED_PATTERNS_CHECKER , builder, props, Scope.SINGLETON); + alias(DateFormatter.class, StrutsConstants.STRUTS_DATE_FORMATTER, builder, props, Scope.SINGLETON); + switchDevMode(props); } diff --git a/core/src/main/resources/org/apache/struts2/default.properties b/core/src/main/resources/org/apache/struts2/default.properties index 571dcf59e..57b692a32 100644 --- a/core/src/main/resources/org/apache/struts2/default.properties +++ b/core/src/main/resources/org/apache/struts2/default.properties @@ -243,4 +243,10 @@ struts.handle.exception=true ### NOTE: The sample line below is *INTENTIONALLY* commented out, as this feature is disabled by default. # struts.ognl.expressionMaxLength=256 +### Defines which named instance of DateFormatter to use, there are two instances: +### - simpleDateFormatter (based on SimpleDateFormat) +### - dateTimeFormatter (based on Java 8 Date/Time API) +### These formatters are using a slightly different patterns, please check JavaDocs for from details and WW-5016 +struts.date.formatter=dateTimeFormatter + ### END SNIPPET: complete_file diff --git a/core/src/main/resources/struts-default.xml b/core/src/main/resources/struts-default.xml index 9dd8fbfa3..96b17b413 100644 --- a/core/src/main/resources/struts-default.xml +++ b/core/src/main/resources/struts-default.xml @@ -216,7 +216,7 @@ - + @@ -228,6 +228,9 @@ + + + diff --git a/core/src/test/java/org/apache/struts2/components/DateTest.java b/core/src/test/java/org/apache/struts2/components/DateTest.java new file mode 100644 index 000000000..2b9ca8bd7 --- /dev/null +++ b/core/src/test/java/org/apache/struts2/components/DateTest.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.components; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.util.ValueStack; +import com.opensymphony.xwork2.util.ValueStackFactory; +import org.apache.struts2.StrutsInternalTestCase; +import org.apache.struts2.components.date.SimpleDateFormatAdapter; + +import java.io.StringWriter; +import java.io.Writer; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Map; + +public class DateTest extends StrutsInternalTestCase { + + private Map context; + private ValueStack stack; + + public void testSupportSimpleDateTimeFormat() { + // given + Date date = new Date(stack); + date.setDateFormatter(new SimpleDateFormatAdapter()); + + String format = "EEEE MMMM dd, hh:mm aa"; + java.util.Date now = new java.util.Date(); + + String expected = new SimpleDateFormat(format, ActionContext.getContext().getLocale()).format(now); + context.put("myDate", now); + + Writer writer = new StringWriter(); + + // when + date.setFormat(format); + date.setName("myDate"); + date.setNice(false); + date.start(writer); + date.end(writer, ""); + + // then + assertEquals(expected, writer.toString()); + } + + public void testDefaultFormat() { + // given + Date date = new Date(stack); + date.setDateFormatter(new SimpleDateFormatAdapter()); + + java.util.Date now = new java.util.Date(); + + String expected = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, ActionContext.getContext().getLocale()).format(now); + context.put("myDate", now); + + Writer writer = new StringWriter(); + + // when + date.setName("myDate"); + date.setNice(false); + date.start(writer); + date.end(writer, ""); + + // then + assertEquals(expected, writer.toString()); + } + + @Override + public void setUp() throws Exception { + super.setUp(); + stack = container.getInstance(ValueStackFactory.class).createValueStack(); + context = stack.getContext(); + } +} From 5648721d07b483427ed00c4315b91f45cd359918 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sun, 20 Feb 2022 13:33:49 +0100 Subject: [PATCH 26/33] WW-5016 Fixes typo in instance name --- .../config/providers/StrutsDefaultConfigurationProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java index a5dcf99cb..f93237367 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java @@ -222,7 +222,7 @@ public class StrutsDefaultConfigurationProvider implements ConfigurationProvider .factory(ValueSubstitutor.class, EnvsValueSubstitutor.class, Scope.SINGLETON) - .factory(DateFormatter.class, "simpleDateFormat", SimpleDateFormatAdapter.class, Scope.SINGLETON) + .factory(DateFormatter.class, "simpleDateFormatter", SimpleDateFormatAdapter.class, Scope.SINGLETON) .factory(DateFormatter.class, "dateTimeFormatter", DateTimeFormatterAdapter.class, Scope.SINGLETON) ; From 4746a49d177baee9d99acd243c2aec627828b2bc Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Mon, 21 Feb 2022 08:47:36 +0100 Subject: [PATCH 27/33] WW-5016 Improves description of different patterns --- core/src/main/resources/org/apache/struts2/default.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/org/apache/struts2/default.properties b/core/src/main/resources/org/apache/struts2/default.properties index 57b692a32..4456d10af 100644 --- a/core/src/main/resources/org/apache/struts2/default.properties +++ b/core/src/main/resources/org/apache/struts2/default.properties @@ -246,7 +246,7 @@ struts.handle.exception=true ### Defines which named instance of DateFormatter to use, there are two instances: ### - simpleDateFormatter (based on SimpleDateFormat) ### - dateTimeFormatter (based on Java 8 Date/Time API) -### These formatters are using a slightly different patterns, please check JavaDocs for from details and WW-5016 +### These formatters are using a slightly different patterns, please check JavaDocs of both and more details is in WW-5016 struts.date.formatter=dateTimeFormatter ### END SNIPPET: complete_file From 59932a51799890582859938a355546b75b5f6834 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Mon, 21 Feb 2022 19:31:52 +0100 Subject: [PATCH 28/33] WW-5016 Reduces calls to TextProvider --- .../org/apache/struts2/components/Date.java | 19 ++++++++++--------- .../components/date/DateFormatter.java | 11 +++++++++-- .../date/DateTimeFormatterAdapter.java | 10 +++------- .../date/SimpleDateFormatAdapter.java | 8 ++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/components/Date.java b/core/src/main/java/org/apache/struts2/components/Date.java index 0560057b8..ad174fd11 100644 --- a/core/src/main/java/org/apache/struts2/components/Date.java +++ b/core/src/main/java/org/apache/struts2/components/Date.java @@ -23,7 +23,6 @@ import com.opensymphony.xwork2.inject.Inject; import com.opensymphony.xwork2.util.ValueStack; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.struts2.StrutsConstants; import org.apache.struts2.components.date.DateFormatter; import org.apache.struts2.views.annotations.StrutsTag; import org.apache.struts2.views.annotations.StrutsTagAttribute; @@ -355,15 +354,17 @@ public class Date extends ContextBean { } private String formatDate(TextProvider textProvider, ZonedDateTime date) { - // if the format is not specified, fall back using the defined property DATETAG_PROPERTY - String globalFormat = textProvider.getText(Date.DATETAG_PROPERTY); - if (DATETAG_PROPERTY.equals(globalFormat)) { - // if tp.getText can not find the property then the - // returned string is the same as input = DATETAG_PROPERTY - globalFormat = null; + String useFormat = format; + if (useFormat == null) { + // if the format is not specified, fall back using the defined property DATETAG_PROPERTY + useFormat = textProvider.getText(DATETAG_PROPERTY); + if (DATETAG_PROPERTY.equals(useFormat)) { + // if tp.getText can not find the property then the + // returned string is the same as input = DATETAG_PROPERTY + useFormat = null; + } } - - return dateFormatter.format(date, format, globalFormat); + return dateFormatter.format(date, useFormat); } private ZoneId getTimeZone() { diff --git a/core/src/main/java/org/apache/struts2/components/date/DateFormatter.java b/core/src/main/java/org/apache/struts2/components/date/DateFormatter.java index 7ad276a25..282daaa06 100644 --- a/core/src/main/java/org/apache/struts2/components/date/DateFormatter.java +++ b/core/src/main/java/org/apache/struts2/components/date/DateFormatter.java @@ -23,11 +23,18 @@ import java.time.temporal.TemporalAccessor; /** * Allows defines a wrapper around different formatting APIs, like old SimpleDateFormat * and new DateTimeFormatter introduced in Java 8 Date/Time API - * + *

* New instance will be injected using {@link org.apache.struts2.StrutsConstants#STRUTS_DATE_FORMATTER} */ public interface DateFormatter { - String format(TemporalAccessor temporal, String format, String defaultFormat); + /** + * Formats provided temporal with the given format + * + * @param temporal Java 8 {@link TemporalAccessor} + * @param format implementation specific format + * @return a string representation of the formatted `temporal` + */ + String format(TemporalAccessor temporal, String format); } diff --git a/core/src/main/java/org/apache/struts2/components/date/DateTimeFormatterAdapter.java b/core/src/main/java/org/apache/struts2/components/date/DateTimeFormatterAdapter.java index 64bb4b165..05767ab1b 100644 --- a/core/src/main/java/org/apache/struts2/components/date/DateTimeFormatterAdapter.java +++ b/core/src/main/java/org/apache/struts2/components/date/DateTimeFormatterAdapter.java @@ -28,16 +28,12 @@ import java.util.Locale; public class DateTimeFormatterAdapter implements DateFormatter { @Override - public String format(TemporalAccessor temporal, String format, String defaultFormat) { + public String format(TemporalAccessor temporal, String format) { DateTimeFormatter dtf; Locale locale = ActionContext.getContext().getLocale(); if (format == null) { - if (defaultFormat != null) { - dtf = DateTimeFormatter.ofPattern(defaultFormat, locale); - } else { - dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) - .withLocale(locale); - } + dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) + .withLocale(locale); } else { dtf = DateTimeFormatter.ofPattern(format, locale); } diff --git a/core/src/main/java/org/apache/struts2/components/date/SimpleDateFormatAdapter.java b/core/src/main/java/org/apache/struts2/components/date/SimpleDateFormatAdapter.java index e9f29f0be..38f3c5296 100644 --- a/core/src/main/java/org/apache/struts2/components/date/SimpleDateFormatAdapter.java +++ b/core/src/main/java/org/apache/struts2/components/date/SimpleDateFormatAdapter.java @@ -30,15 +30,11 @@ import java.util.Locale; public class SimpleDateFormatAdapter implements DateFormatter { @Override - public String format(TemporalAccessor temporal, String format, String defaultFormat) { + public String format(TemporalAccessor temporal, String format) { DateFormat df; Locale locale = ActionContext.getContext().getLocale(); if (format == null) { - if (defaultFormat != null) { - df = new SimpleDateFormat(defaultFormat, locale); - } else { - df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, locale); - } + df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, locale); } else { df = new SimpleDateFormat(format, locale); } From 0c9f9c3400f1a91e01e06c4bfcd9ea12f9245ec5 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 24 Feb 2022 07:11:13 +0100 Subject: [PATCH 29/33] [maven-release-plugin] prepare release STRUTS_6_0_0_RC3 --- apps/pom.xml | 2 +- apps/rest-showcase/pom.xml | 4 ++-- apps/showcase/pom.xml | 2 +- assembly/pom.xml | 2 +- bom/pom.xml | 6 +++--- bundles/admin/pom.xml | 2 +- bundles/demo/pom.xml | 2 +- bundles/pom.xml | 2 +- core/pom.xml | 2 +- plugins/async/pom.xml | 2 +- plugins/bean-validation/pom.xml | 2 +- plugins/cdi/pom.xml | 2 +- plugins/config-browser/pom.xml | 2 +- plugins/convention/pom.xml | 2 +- plugins/dwr/pom.xml | 2 +- plugins/embeddedjsp/pom.xml | 2 +- plugins/gxp/pom.xml | 2 +- plugins/jasperreports/pom.xml | 2 +- plugins/javatemplates/pom.xml | 2 +- plugins/jfreechart/pom.xml | 2 +- plugins/json/pom.xml | 2 +- plugins/junit/pom.xml | 2 +- plugins/osgi/pom.xml | 2 +- plugins/oval/pom.xml | 2 +- plugins/pell-multipart/pom.xml | 2 +- plugins/plexus/pom.xml | 2 +- plugins/pom.xml | 2 +- plugins/portlet-mocks/pom.xml | 2 +- plugins/portlet-tiles/pom.xml | 2 +- plugins/portlet/pom.xml | 2 +- plugins/rest/pom.xml | 2 +- plugins/sitemesh/pom.xml | 2 +- plugins/spring/pom.xml | 2 +- plugins/testng/pom.xml | 2 +- plugins/tiles/pom.xml | 2 +- plugins/velocity/pom.xml | 2 +- pom.xml | 6 +++--- 37 files changed, 42 insertions(+), 42 deletions(-) diff --git a/apps/pom.xml b/apps/pom.xml index 54e3b841a..d95021ec1 100644 --- a/apps/pom.xml +++ b/apps/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-apps pom diff --git a/apps/rest-showcase/pom.xml b/apps/rest-showcase/pom.xml index 56533ec53..89a2d38f6 100644 --- a/apps/rest-showcase/pom.xml +++ b/apps/rest-showcase/pom.xml @@ -24,12 +24,12 @@ org.apache.struts struts2-apps - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-rest-showcase war - 6.0.0-SNAPSHOT + 6.0.0-RC3 Struts 2 Rest Showcase Webapp Struts 2 Rest Showcase Example diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml index 9ce5d0b6c..8dd06cd5b 100644 --- a/apps/showcase/pom.xml +++ b/apps/showcase/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-apps - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-showcase diff --git a/assembly/pom.xml b/assembly/pom.xml index 5abd8547c..4f7098696 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-assembly diff --git a/bom/pom.xml b/bom/pom.xml index 021a767b2..94fbce1ab 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -29,7 +29,7 @@ struts2-bom - 6.0.0-SNAPSHOT + 6.0.0-RC3 pom Struts 2 Bill of Materials @@ -44,7 +44,7 @@ - 6.0.0-SNAPSHOT + 6.0.0-RC3 true true @@ -175,7 +175,7 @@ - HEAD + STRUTS_6_0_0_RC3 scm:git:https://gitbox.apache.org/repos/asf/struts.git scm:git:https://gitbox.apache.org/repos/asf/struts.git https://github.com/apache/struts/ diff --git a/bundles/admin/pom.xml b/bundles/admin/pom.xml index 4f5ce6cc2..32a765800 100644 --- a/bundles/admin/pom.xml +++ b/bundles/admin/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-osgi-bundles - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-osgi-admin-bundle diff --git a/bundles/demo/pom.xml b/bundles/demo/pom.xml index df1cd3231..16a651750 100644 --- a/bundles/demo/pom.xml +++ b/bundles/demo/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-osgi-bundles - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-osgi-demo-bundle diff --git a/bundles/pom.xml b/bundles/pom.xml index 606f2358f..cdd89e37e 100755 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-osgi-bundles diff --git a/core/pom.xml b/core/pom.xml index 4ae6fa027..f44b89af0 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-core jar diff --git a/plugins/async/pom.xml b/plugins/async/pom.xml index 8512e1986..17585d2ff 100644 --- a/plugins/async/pom.xml +++ b/plugins/async/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-async-plugin diff --git a/plugins/bean-validation/pom.xml b/plugins/bean-validation/pom.xml index b59367509..4d105b670 100644 --- a/plugins/bean-validation/pom.xml +++ b/plugins/bean-validation/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 4.0.0 diff --git a/plugins/cdi/pom.xml b/plugins/cdi/pom.xml index 7dde20b68..2ad551124 100644 --- a/plugins/cdi/pom.xml +++ b/plugins/cdi/pom.xml @@ -25,7 +25,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-cdi-plugin diff --git a/plugins/config-browser/pom.xml b/plugins/config-browser/pom.xml index e4e609bdf..98ede7875 100644 --- a/plugins/config-browser/pom.xml +++ b/plugins/config-browser/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-config-browser-plugin diff --git a/plugins/convention/pom.xml b/plugins/convention/pom.xml index 6bde5d2fa..0e0e283a6 100644 --- a/plugins/convention/pom.xml +++ b/plugins/convention/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-convention-plugin diff --git a/plugins/dwr/pom.xml b/plugins/dwr/pom.xml index 9426ed66b..2a6bd6cf2 100644 --- a/plugins/dwr/pom.xml +++ b/plugins/dwr/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-dwr-plugin diff --git a/plugins/embeddedjsp/pom.xml b/plugins/embeddedjsp/pom.xml index f8c56b547..bad55e417 100644 --- a/plugins/embeddedjsp/pom.xml +++ b/plugins/embeddedjsp/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-embeddedjsp-plugin diff --git a/plugins/gxp/pom.xml b/plugins/gxp/pom.xml index 42908e4f3..19dd91f6d 100644 --- a/plugins/gxp/pom.xml +++ b/plugins/gxp/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-gxp-plugin diff --git a/plugins/jasperreports/pom.xml b/plugins/jasperreports/pom.xml index eb0eb0808..f74ab828d 100644 --- a/plugins/jasperreports/pom.xml +++ b/plugins/jasperreports/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-jasperreports-plugin diff --git a/plugins/javatemplates/pom.xml b/plugins/javatemplates/pom.xml index a66f5514f..97e93b37e 100644 --- a/plugins/javatemplates/pom.xml +++ b/plugins/javatemplates/pom.xml @@ -25,7 +25,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-javatemplates-plugin diff --git a/plugins/jfreechart/pom.xml b/plugins/jfreechart/pom.xml index 30681863f..45eadca34 100644 --- a/plugins/jfreechart/pom.xml +++ b/plugins/jfreechart/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-jfreechart-plugin diff --git a/plugins/json/pom.xml b/plugins/json/pom.xml index 4f9004cc5..84328d639 100644 --- a/plugins/json/pom.xml +++ b/plugins/json/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-json-plugin diff --git a/plugins/junit/pom.xml b/plugins/junit/pom.xml index 4a7e51369..ab069597e 100644 --- a/plugins/junit/pom.xml +++ b/plugins/junit/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-junit-plugin diff --git a/plugins/osgi/pom.xml b/plugins/osgi/pom.xml index dfdc0557f..2a76ff8ff 100644 --- a/plugins/osgi/pom.xml +++ b/plugins/osgi/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-osgi-plugin diff --git a/plugins/oval/pom.xml b/plugins/oval/pom.xml index f27298471..d064cbe4a 100644 --- a/plugins/oval/pom.xml +++ b/plugins/oval/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-oval-plugin diff --git a/plugins/pell-multipart/pom.xml b/plugins/pell-multipart/pom.xml index 5de775f10..a463d46e1 100644 --- a/plugins/pell-multipart/pom.xml +++ b/plugins/pell-multipart/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-pell-multipart-plugin diff --git a/plugins/plexus/pom.xml b/plugins/plexus/pom.xml index 7b9e9cd87..7a57ae2e3 100644 --- a/plugins/plexus/pom.xml +++ b/plugins/plexus/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-plexus-plugin diff --git a/plugins/pom.xml b/plugins/pom.xml index 4150947c4..aa8c80f77 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-plugins diff --git a/plugins/portlet-mocks/pom.xml b/plugins/portlet-mocks/pom.xml index e4bf15a00..adf92d4f3 100644 --- a/plugins/portlet-mocks/pom.xml +++ b/plugins/portlet-mocks/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-portlet-mocks-plugin diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml index 4a77faa82..03e20e20a 100644 --- a/plugins/portlet-tiles/pom.xml +++ b/plugins/portlet-tiles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-portlet-tiles-plugin diff --git a/plugins/portlet/pom.xml b/plugins/portlet/pom.xml index da4bc9bf0..f887af2d2 100644 --- a/plugins/portlet/pom.xml +++ b/plugins/portlet/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-portlet-plugin diff --git a/plugins/rest/pom.xml b/plugins/rest/pom.xml index 73efaff36..413514263 100644 --- a/plugins/rest/pom.xml +++ b/plugins/rest/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-rest-plugin diff --git a/plugins/sitemesh/pom.xml b/plugins/sitemesh/pom.xml index af6ce18e6..a61580d3b 100644 --- a/plugins/sitemesh/pom.xml +++ b/plugins/sitemesh/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-sitemesh-plugin diff --git a/plugins/spring/pom.xml b/plugins/spring/pom.xml index 087c3b398..b1d2f6e36 100644 --- a/plugins/spring/pom.xml +++ b/plugins/spring/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-spring-plugin diff --git a/plugins/testng/pom.xml b/plugins/testng/pom.xml index 78aad4319..76d69c8db 100644 --- a/plugins/testng/pom.xml +++ b/plugins/testng/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-testng-plugin diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml index 7bfeef7ea..f21a1ad9d 100644 --- a/plugins/tiles/pom.xml +++ b/plugins/tiles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-tiles-plugin diff --git a/plugins/velocity/pom.xml b/plugins/velocity/pom.xml index 8a2c69a80..3331f69c3 100644 --- a/plugins/velocity/pom.xml +++ b/plugins/velocity/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-SNAPSHOT + 6.0.0-RC3 struts2-velocity-plugin diff --git a/pom.xml b/pom.xml index 8b0e7712a..2dfc98769 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 4.0.0 struts2-parent - 6.0.0-SNAPSHOT + 6.0.0-RC3 pom Struts 2 http://struts.apache.org/ @@ -51,7 +51,7 @@ scm:git:https://gitbox.apache.org/repos/asf/struts.git scm:git:https://gitbox.apache.org/repos/asf/struts.git https://github.com/apache/struts/ - HEAD + STRUTS_6_0_0_RC3 @@ -104,7 +104,7 @@ UTF-8 - 2022-01-29T16:36:34Z + 2022-02-24T06:07:09Z 1.8 From 115fef2af78f6b28108cfefbc9e5c41aff923dbb Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 24 Feb 2022 07:11:22 +0100 Subject: [PATCH 30/33] [maven-release-plugin] prepare for next development iteration --- apps/pom.xml | 2 +- apps/rest-showcase/pom.xml | 4 ++-- apps/showcase/pom.xml | 2 +- assembly/pom.xml | 2 +- bom/pom.xml | 6 +++--- bundles/admin/pom.xml | 2 +- bundles/demo/pom.xml | 2 +- bundles/pom.xml | 2 +- core/pom.xml | 2 +- plugins/async/pom.xml | 2 +- plugins/bean-validation/pom.xml | 2 +- plugins/cdi/pom.xml | 2 +- plugins/config-browser/pom.xml | 2 +- plugins/convention/pom.xml | 2 +- plugins/dwr/pom.xml | 2 +- plugins/embeddedjsp/pom.xml | 2 +- plugins/gxp/pom.xml | 2 +- plugins/jasperreports/pom.xml | 2 +- plugins/javatemplates/pom.xml | 2 +- plugins/jfreechart/pom.xml | 2 +- plugins/json/pom.xml | 2 +- plugins/junit/pom.xml | 2 +- plugins/osgi/pom.xml | 2 +- plugins/oval/pom.xml | 2 +- plugins/pell-multipart/pom.xml | 2 +- plugins/plexus/pom.xml | 2 +- plugins/pom.xml | 2 +- plugins/portlet-mocks/pom.xml | 2 +- plugins/portlet-tiles/pom.xml | 2 +- plugins/portlet/pom.xml | 2 +- plugins/rest/pom.xml | 2 +- plugins/sitemesh/pom.xml | 2 +- plugins/spring/pom.xml | 2 +- plugins/testng/pom.xml | 2 +- plugins/tiles/pom.xml | 2 +- plugins/velocity/pom.xml | 2 +- pom.xml | 6 +++--- 37 files changed, 42 insertions(+), 42 deletions(-) diff --git a/apps/pom.xml b/apps/pom.xml index d95021ec1..54e3b841a 100644 --- a/apps/pom.xml +++ b/apps/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-apps pom diff --git a/apps/rest-showcase/pom.xml b/apps/rest-showcase/pom.xml index 89a2d38f6..56533ec53 100644 --- a/apps/rest-showcase/pom.xml +++ b/apps/rest-showcase/pom.xml @@ -24,12 +24,12 @@ org.apache.struts struts2-apps - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-rest-showcase war - 6.0.0-RC3 + 6.0.0-SNAPSHOT Struts 2 Rest Showcase Webapp Struts 2 Rest Showcase Example diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml index 8dd06cd5b..9ce5d0b6c 100644 --- a/apps/showcase/pom.xml +++ b/apps/showcase/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-apps - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-showcase diff --git a/assembly/pom.xml b/assembly/pom.xml index 4f7098696..5abd8547c 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-assembly diff --git a/bom/pom.xml b/bom/pom.xml index 94fbce1ab..021a767b2 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -29,7 +29,7 @@ struts2-bom - 6.0.0-RC3 + 6.0.0-SNAPSHOT pom Struts 2 Bill of Materials @@ -44,7 +44,7 @@ - 6.0.0-RC3 + 6.0.0-SNAPSHOT true true @@ -175,7 +175,7 @@ - STRUTS_6_0_0_RC3 + HEAD scm:git:https://gitbox.apache.org/repos/asf/struts.git scm:git:https://gitbox.apache.org/repos/asf/struts.git https://github.com/apache/struts/ diff --git a/bundles/admin/pom.xml b/bundles/admin/pom.xml index 32a765800..4f5ce6cc2 100644 --- a/bundles/admin/pom.xml +++ b/bundles/admin/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-osgi-bundles - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-osgi-admin-bundle diff --git a/bundles/demo/pom.xml b/bundles/demo/pom.xml index 16a651750..df1cd3231 100644 --- a/bundles/demo/pom.xml +++ b/bundles/demo/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-osgi-bundles - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-osgi-demo-bundle diff --git a/bundles/pom.xml b/bundles/pom.xml index cdd89e37e..606f2358f 100755 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-osgi-bundles diff --git a/core/pom.xml b/core/pom.xml index f44b89af0..4ae6fa027 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-core jar diff --git a/plugins/async/pom.xml b/plugins/async/pom.xml index 17585d2ff..8512e1986 100644 --- a/plugins/async/pom.xml +++ b/plugins/async/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-async-plugin diff --git a/plugins/bean-validation/pom.xml b/plugins/bean-validation/pom.xml index 4d105b670..b59367509 100644 --- a/plugins/bean-validation/pom.xml +++ b/plugins/bean-validation/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT 4.0.0 diff --git a/plugins/cdi/pom.xml b/plugins/cdi/pom.xml index 2ad551124..7dde20b68 100644 --- a/plugins/cdi/pom.xml +++ b/plugins/cdi/pom.xml @@ -25,7 +25,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-cdi-plugin diff --git a/plugins/config-browser/pom.xml b/plugins/config-browser/pom.xml index 98ede7875..e4e609bdf 100644 --- a/plugins/config-browser/pom.xml +++ b/plugins/config-browser/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-config-browser-plugin diff --git a/plugins/convention/pom.xml b/plugins/convention/pom.xml index 0e0e283a6..6bde5d2fa 100644 --- a/plugins/convention/pom.xml +++ b/plugins/convention/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-convention-plugin diff --git a/plugins/dwr/pom.xml b/plugins/dwr/pom.xml index 2a6bd6cf2..9426ed66b 100644 --- a/plugins/dwr/pom.xml +++ b/plugins/dwr/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-dwr-plugin diff --git a/plugins/embeddedjsp/pom.xml b/plugins/embeddedjsp/pom.xml index bad55e417..f8c56b547 100644 --- a/plugins/embeddedjsp/pom.xml +++ b/plugins/embeddedjsp/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-embeddedjsp-plugin diff --git a/plugins/gxp/pom.xml b/plugins/gxp/pom.xml index 19dd91f6d..42908e4f3 100644 --- a/plugins/gxp/pom.xml +++ b/plugins/gxp/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-gxp-plugin diff --git a/plugins/jasperreports/pom.xml b/plugins/jasperreports/pom.xml index f74ab828d..eb0eb0808 100644 --- a/plugins/jasperreports/pom.xml +++ b/plugins/jasperreports/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-jasperreports-plugin diff --git a/plugins/javatemplates/pom.xml b/plugins/javatemplates/pom.xml index 97e93b37e..a66f5514f 100644 --- a/plugins/javatemplates/pom.xml +++ b/plugins/javatemplates/pom.xml @@ -25,7 +25,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-javatemplates-plugin diff --git a/plugins/jfreechart/pom.xml b/plugins/jfreechart/pom.xml index 45eadca34..30681863f 100644 --- a/plugins/jfreechart/pom.xml +++ b/plugins/jfreechart/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-jfreechart-plugin diff --git a/plugins/json/pom.xml b/plugins/json/pom.xml index 84328d639..4f9004cc5 100644 --- a/plugins/json/pom.xml +++ b/plugins/json/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-json-plugin diff --git a/plugins/junit/pom.xml b/plugins/junit/pom.xml index ab069597e..4a7e51369 100644 --- a/plugins/junit/pom.xml +++ b/plugins/junit/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-junit-plugin diff --git a/plugins/osgi/pom.xml b/plugins/osgi/pom.xml index 2a76ff8ff..dfdc0557f 100644 --- a/plugins/osgi/pom.xml +++ b/plugins/osgi/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-osgi-plugin diff --git a/plugins/oval/pom.xml b/plugins/oval/pom.xml index d064cbe4a..f27298471 100644 --- a/plugins/oval/pom.xml +++ b/plugins/oval/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-oval-plugin diff --git a/plugins/pell-multipart/pom.xml b/plugins/pell-multipart/pom.xml index a463d46e1..5de775f10 100644 --- a/plugins/pell-multipart/pom.xml +++ b/plugins/pell-multipart/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-pell-multipart-plugin diff --git a/plugins/plexus/pom.xml b/plugins/plexus/pom.xml index 7a57ae2e3..7b9e9cd87 100644 --- a/plugins/plexus/pom.xml +++ b/plugins/plexus/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-plexus-plugin diff --git a/plugins/pom.xml b/plugins/pom.xml index aa8c80f77..4150947c4 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-parent - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-plugins diff --git a/plugins/portlet-mocks/pom.xml b/plugins/portlet-mocks/pom.xml index adf92d4f3..e4bf15a00 100644 --- a/plugins/portlet-mocks/pom.xml +++ b/plugins/portlet-mocks/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-portlet-mocks-plugin diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml index 03e20e20a..4a77faa82 100644 --- a/plugins/portlet-tiles/pom.xml +++ b/plugins/portlet-tiles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-portlet-tiles-plugin diff --git a/plugins/portlet/pom.xml b/plugins/portlet/pom.xml index f887af2d2..da4bc9bf0 100644 --- a/plugins/portlet/pom.xml +++ b/plugins/portlet/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-portlet-plugin diff --git a/plugins/rest/pom.xml b/plugins/rest/pom.xml index 413514263..73efaff36 100644 --- a/plugins/rest/pom.xml +++ b/plugins/rest/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-rest-plugin diff --git a/plugins/sitemesh/pom.xml b/plugins/sitemesh/pom.xml index a61580d3b..af6ce18e6 100644 --- a/plugins/sitemesh/pom.xml +++ b/plugins/sitemesh/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-sitemesh-plugin diff --git a/plugins/spring/pom.xml b/plugins/spring/pom.xml index b1d2f6e36..087c3b398 100644 --- a/plugins/spring/pom.xml +++ b/plugins/spring/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-spring-plugin diff --git a/plugins/testng/pom.xml b/plugins/testng/pom.xml index 76d69c8db..78aad4319 100644 --- a/plugins/testng/pom.xml +++ b/plugins/testng/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-testng-plugin diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml index f21a1ad9d..7bfeef7ea 100644 --- a/plugins/tiles/pom.xml +++ b/plugins/tiles/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-tiles-plugin diff --git a/plugins/velocity/pom.xml b/plugins/velocity/pom.xml index 3331f69c3..8a2c69a80 100644 --- a/plugins/velocity/pom.xml +++ b/plugins/velocity/pom.xml @@ -24,7 +24,7 @@ org.apache.struts struts2-plugins - 6.0.0-RC3 + 6.0.0-SNAPSHOT struts2-velocity-plugin diff --git a/pom.xml b/pom.xml index 2dfc98769..a32aa5611 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ 4.0.0 struts2-parent - 6.0.0-RC3 + 6.0.0-SNAPSHOT pom Struts 2 http://struts.apache.org/ @@ -51,7 +51,7 @@ scm:git:https://gitbox.apache.org/repos/asf/struts.git scm:git:https://gitbox.apache.org/repos/asf/struts.git https://github.com/apache/struts/ - STRUTS_6_0_0_RC3 + HEAD @@ -104,7 +104,7 @@ UTF-8 - 2022-02-24T06:07:09Z + 2022-02-24T06:11:22Z 1.8 From 8b11a3873aef5db0a4771e5939bb9b9af055f1ad Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Tue, 1 Mar 2022 08:10:00 +0100 Subject: [PATCH 31/33] WW-5171 Upgrades Log4j to version 2.17.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a32aa5611..c1a7f67e1 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,7 @@ 9.2 2.10.5 2.10.5.1 - 2.17.1 + 2.17.2 3.3.2 1.7.32 4.3.30.RELEASE From 84164c422e63a7f077cfdaa4d5ed036772a4718c Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Thu, 3 Mar 2022 12:18:11 +0100 Subject: [PATCH 32/33] Drops unused dependency --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index c1a7f67e1..cc586d653 100644 --- a/pom.xml +++ b/pom.xml @@ -933,12 +933,6 @@ commons-collections4 4.4 - - - commons-collections - commons-collections - 3.2.2 - commons-fileupload commons-fileupload From c0940529690697611aaab38ea9ea1186d909267b Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Fri, 4 Mar 2022 12:52:33 +0100 Subject: [PATCH 33/33] Uses Java Reflections instead BeanUtils to read property --- .../BeanValidationExampleAction.java | 30 ++++--- .../annotations/TypeConversion.java | 3 +- plugins/bean-validation/pom.xml | 18 ++-- .../constraints/impl/FieldMatchValidator.java | 21 ++++- .../impl/FieldMatchValidatorTest.java | 84 +++++++++++++++++++ pom.xml | 2 +- 6 files changed, 130 insertions(+), 28 deletions(-) create mode 100644 plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/constraints/impl/FieldMatchValidatorTest.java diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/BeanValidationExampleAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/BeanValidationExampleAction.java index 67190e035..4c07f51e9 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/BeanValidationExampleAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/BeanValidationExampleAction.java @@ -27,22 +27,24 @@ import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.ParentPackage; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.interceptor.validation.SkipValidation; -import org.hibernate.validator.constraints.Email; -import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.ScriptAssert; import org.hibernate.validator.constraints.URL; -import javax.validation.constraints.*; +import javax.validation.constraints.Email; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; import java.util.Date; -/** - * - */ +// @Namespace("/bean-validation") @ParentPackage("bean-validation") @Action(results = { - @Result(name = "input", location = "bean-validation.jsp"), - @Result(name = "success", location = "/WEB-INF/validation/successFieldValidatorsExample.jsp") + @Result(name = "input", location = "bean-validation.jsp"), + @Result(name = "success", location = "/WEB-INF/validation/successFieldValidatorsExample.jsp") }) @FieldMatch(first = "fieldExpressionValidatorField", second = "requiredValidatorField", message = "requiredValidatorField and fieldExpressionValidatorField are not matching") @ScriptAssert(lang = "javascript", script = "_this.dateValidatorField != null && _this.dateValidatorField.before(new java.util.Date())", message = "Date need to before now") @@ -82,10 +84,10 @@ public class BeanValidationExampleAction extends ActionSupport { private String fieldExpressionValidatorField = null; @Action(value = "bean-validation", results = { - @Result(name = "success", location = "bean-validation.jsp") + @Result(name = "success", location = "bean-validation.jsp") }) @SkipValidation - public String beanValidation(){ + public String beanValidation() { return SUCCESS; } @@ -150,7 +152,7 @@ public class BeanValidationExampleAction extends ActionSupport { } public void setFieldExpressionValidatorField( - String fieldExpressionValidatorField) { + String fieldExpressionValidatorField) { this.fieldExpressionValidatorField = fieldExpressionValidatorField; } @@ -163,8 +165,4 @@ public class BeanValidationExampleAction extends ActionSupport { } } -/** - * - */ - - +// diff --git a/core/src/main/java/com/opensymphony/xwork2/conversion/annotations/TypeConversion.java b/core/src/main/java/com/opensymphony/xwork2/conversion/annotations/TypeConversion.java index 6c86d4a6d..eda8a585a 100644 --- a/core/src/main/java/com/opensymphony/xwork2/conversion/annotations/TypeConversion.java +++ b/core/src/main/java/com/opensymphony/xwork2/conversion/annotations/TypeConversion.java @@ -38,7 +38,8 @@ import java.lang.annotation.Target; * *

* Application wide conversion:
- * The conversion rules will be assembled within the xwork-conversion.properties file within the classpath root. + * The conversion rules will be assembled within the struts-conversion.properties or + * xwork-conversion.properties (deprecated) file within the classpath root. * Set type to: type = ConversionType.APPLICATION *

* diff --git a/plugins/bean-validation/pom.xml b/plugins/bean-validation/pom.xml index b59367509..aed8f05f5 100644 --- a/plugins/bean-validation/pom.xml +++ b/plugins/bean-validation/pom.xml @@ -44,11 +44,6 @@ 2.0.1.Final - - commons-beanutils - commons-beanutils - - org.hibernate hibernate-validator @@ -60,6 +55,17 @@ javax.el test + + org.mockito + mockito-core + test + + + + org.objenesis + objenesis + 3.2 +