[struts-site] branch WW-4173-disable created (now 35061d6e5)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch WW-4173-disable in repository https://gitbox.apache.org/repos/asf/struts-site.git at 35061d6e5 WW-4173 Adds note about how to disable interceptor This branch includes the following new commits: new 35061d6e5 WW-4173 Adds note about how to disable interceptor The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[struts-site] 01/01: WW-4173 Adds note about how to disable interceptor
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-4173-disable in repository https://gitbox.apache.org/repos/asf/struts-site.git commit 35061d6e5ea95dcbacbed559650f4266cb124712 Author: Lukasz Lenart AuthorDate: Wed Oct 26 09:03:50 2022 +0200 WW-4173 Adds note about how to disable interceptor --- source/core-developers/interceptors.md | 29 + 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/source/core-developers/interceptors.md b/source/core-developers/interceptors.md index 36ec68530..ad050f667 100644 --- a/source/core-developers/interceptors.md +++ b/source/core-developers/interceptors.md @@ -1,9 +1,6 @@ --- layout: core-developers title: Interceptors -parent: -title: Core Developers Guide -url: index.html --- # Interceptors @@ -35,7 +32,7 @@ Interceptors can be configured on a per-action basis. Your own custom Intercepto the Interceptors bundled with the framework. Interceptors "set the stage" for the Action classes, doing much of the "heavy lifting" before the Action executes. -**Action Lifecyle** +**Action Lifecycle**  @@ -99,7 +96,7 @@ Looking inside `struts-default.xml`, we can see how it's done. {% remote_file_content https://raw.githubusercontent.com/apache/struts/master/core/src/main/resources/struts-default.xml %} {% endhighlight %} -Since the `struts-default.xml` is included in the application's configuration by default, all of the predefined +Since the `struts-default.xml` is included in the application's configuration by default, all the predefined interceptors and stacks are available "out of the box". ## Framework Interceptors @@ -272,7 +269,7 @@ the other params will be null. This functionality was added in Struts 2.5.9 It is possible to define an interceptor with parameters evaluated during action invocation. In such case -the interceptor must be marked with `WithLazyParams` interface. This must be developer's decision as interceptor +the interceptor must be marked with `WithLazyParams` interface. This must be developer's decision as interceptor must be aware of having those parameters set during invocation and not when the interceptor is created as it happens in normal way. @@ -287,7 +284,7 @@ Params are evaluated as any other expression starting with from action as a top ``` -```xml +```java public class MockLazyInterceptor extends AbstractInterceptor implements WithLazyParams { private String foo = ""; @@ -304,7 +301,23 @@ public class MockLazyInterceptor extends AbstractInterceptor implements WithLazy ``` Please be aware that order of interceptors can matter when want to access parameters passed via request as those -parameters are set by [Parameters Interceptor](parameters-interceptor). +parameters are set by [Parameters Interceptor](parameters-interceptor). + +## Disabling interceptor + +Since Struts 6.1.0 it is possible to _disable_ a given interceptor which won't be executed during action invocation. +All the interceptors extending the `AbstractInterceptor` class (all the base interceptors do so) can use the parameters +overriding logic to set the `disabled` parameter to `true` to skip processing of a given interceptor. + +An example how to disable the Validation interceptor: + +```xml + + +true + + +``` ## Order of Interceptor Execution
[struts-site] branch WW-4173-disable updated: Adds notifications to be sent to proper lists
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-4173-disable in repository https://gitbox.apache.org/repos/asf/struts-site.git The following commit(s) were added to refs/heads/WW-4173-disable by this push: new ffd50682e Adds notifications to be sent to proper lists ffd50682e is described below commit ffd50682ee10b013d987b62e59d52a616942e6ca Author: Lukasz Lenart AuthorDate: Wed Oct 26 09:06:44 2022 +0200 Adds notifications to be sent to proper lists --- .asf.yaml | 11 +++ 1 file changed, 11 insertions(+) diff --git a/.asf.yaml b/.asf.yaml index 53ef7421c..d83f365ae 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -1,4 +1,15 @@ # Documentation https://s.apache.org/asfyaml +notifications: + commits: commits@struts.apache.org + # Send all issue emails (new, closed, comments) to issues@ + issues: iss...@struts.apache.org + # Send new/closed PR notifications to dev@ + pullrequests_status: d...@struts.apache.org + # Send individual PR comments/reviews to issues@ + pullrequests_comment: iss...@struts.apache.org + # Link opened PRs with JIRA + jira_options: link label + staging: profile: ~ whoami: asf-staging
[struts-site] branch asf-staging updated: Updates stage by Jenkins
This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-staging in repository https://gitbox.apache.org/repos/asf/struts-site.git The following commit(s) were added to refs/heads/asf-staging by this push: new 775a893d8 Updates stage by Jenkins 775a893d8 is described below commit 775a893d89c7772902b7f3121df83cec6c8424cd Author: jenkins AuthorDate: Wed Oct 26 07:08:28 2022 + Updates stage by Jenkins --- content/core-developers/interceptors.html | 44 +++--- content/tag-developers/a-tag.html | 16 content/tag-developers/actionerror-tag.html| 16 content/tag-developers/actionmessage-tag.html | 16 content/tag-developers/checkbox-tag.html | 16 content/tag-developers/checkboxlist-tag.html | 16 content/tag-developers/combobox-tag.html | 16 content/tag-developers/component-tag.html | 16 content/tag-developers/datetextfield-tag.html | 16 content/tag-developers/doubleselect-tag.html | 16 content/tag-developers/fielderror-tag.html | 16 content/tag-developers/file-tag.html | 16 content/tag-developers/form-tag.html | 16 content/tag-developers/head-tag.html | 16 content/tag-developers/hidden-tag.html | 16 .../tag-developers/inputtransferselect-tag.html| 16 content/tag-developers/label-tag.html | 16 .../tag-developers/optiontransferselect-tag.html | 16 content/tag-developers/password-tag.html | 16 content/tag-developers/radio-tag.html | 16 content/tag-developers/reset-tag.html | 16 content/tag-developers/select-tag.html | 16 content/tag-developers/submit-tag.html | 16 content/tag-developers/textarea-tag.html | 16 content/tag-developers/textfield-tag.html | 16 content/tag-developers/token-tag.html | 16 content/tag-developers/updownselect-tag.html | 16 27 files changed, 30 insertions(+), 430 deletions(-) diff --git a/content/core-developers/interceptors.html b/content/core-developers/interceptors.html index d5bf0a9cc..0e6587bcd 100644 --- a/content/core-developers/interceptors.html +++ b/content/core-developers/interceptors.html @@ -141,6 +141,7 @@ Interceptor Parameter Overriding Interceptor Parameter Overriding Inheritance Lazy parameters + Disabling interceptor Order of Interceptor Execution @@ -167,7 +168,7 @@ is pluggable, so you can decide exactly which features an Action needs to suppor the Interceptors bundled with the framework. Interceptors “set the stage” for the Action classes, doing much of the “heavy lifting” before the Action executes. -Action Lifecyle +Action Lifecycle @@ -773,7 +774,7 @@ than reiterate the same list of Interceptors, we can bundle these Interceptors t -Since the struts-default.xml is included in the application’s configuration by default, all of the predefined +Since the struts-default.xml is included in the application’s configuration by default, all the predefined interceptors and stacks are available “out of the box”. Framework Interceptors @@ -1103,7 +1104,7 @@ the other params will be null. This functionality was added in Struts 2.5.9 It is possible to define an interceptor with parameters evaluated during action invocation. In such case -the interceptor must be marked with WithLazyParams interface. This must be developer’s decision as interceptor +the interceptor must be marked with WithLazyParams interface. This must be developer’s decision as interceptor must be aware of having those parameters set during invocation and not when the interceptor is created as it happens in normal way. @@ -1117,23 +1118,38 @@ in normal way. -public class MockLazyInterceptor extends AbstractInterceptor implements WithLazyParams { +public class MockLazyInterceptor extends AbstractInterceptor implements WithLazyParams { -private String foo = ""; +private String foo = ""; -public void setFoo(String foo) { -this.foo = foo; -} +public void setFoo(String foo) { +this.foo = foo; +} -public String intercept(ActionInvocation invocation) throws Exception { - -return invocation.invoke(); -} -} +public String intercept(ActionInvocation invocation) throws Exception { + +return invocation.invoke(); +} +} Please be aware that order of interceptors can matter when want to access parameters passed via request as those -parameters are set by Parameters Interceptor. +parameters are set by Parameters Interceptor. + +Disa
[struts-site] branch asf-staging updated: Updates stage by Jenkins
This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-staging in repository https://gitbox.apache.org/repos/asf/struts-site.git The following commit(s) were added to refs/heads/asf-staging by this push: new 49f1ee467 Updates stage by Jenkins 49f1ee467 is described below commit 49f1ee467e17db54bce17020e0a3bf56f109949f Author: jenkins AuthorDate: Wed Oct 26 07:09:01 2022 + Updates stage by Jenkins
[struts-site] branch WW-4173-disable updated: Adds helper to prepare unsubscribe email
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-4173-disable in repository https://gitbox.apache.org/repos/asf/struts-site.git The following commit(s) were added to refs/heads/WW-4173-disable by this push: new 1b1d06061 Adds helper to prepare unsubscribe email 1b1d06061 is described below commit 1b1d06061e709b8fe39eccdb9bfc81c7eb9f8555 Author: Lukasz Lenart AuthorDate: Wed Oct 26 09:30:32 2022 +0200 Adds helper to prepare unsubscribe email --- source/mail.md | 19 +++ 1 file changed, 19 insertions(+) diff --git a/source/mail.md b/source/mail.md index b525684ff..0168fd126 100644 --- a/source/mail.md +++ b/source/mail.md @@ -43,6 +43,25 @@ to unsubscribe someone you can email: {listname}-unsubscribe-badboy=menace@tlp.apache.org ``` +### Unsubscribe from the Users mailing list + + +function generate(form) { + var badBoy=form[0]; + var email = 'user-unsubscribe-' + badBoy.value.replace('@', '=') + '@struts.apache.org'; + var link = document.getElementById('ready-email'); + link.style.visibility = 'visible'; + link.href = 'mailto:' + email; +} + + + +Paste user email address + + +Unsubscribe + + ## Guidelines Mailing lists provide a simple and effective communication mechanism. With potentially thousands of subscribers, there
[struts-site] branch asf-staging updated: Updates stage by Jenkins
This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-staging in repository https://gitbox.apache.org/repos/asf/struts-site.git The following commit(s) were added to refs/heads/asf-staging by this push: new ce6bd68f4 Updates stage by Jenkins ce6bd68f4 is described below commit ce6bd68f439a39db0e575e380879265765a27548 Author: jenkins AuthorDate: Wed Oct 26 07:32:02 2022 + Updates stage by Jenkins --- content/mail.html | 19 +++ 1 file changed, 19 insertions(+) diff --git a/content/mail.html b/content/mail.html index 482e276d9..808b52cbd 100644 --- a/content/mail.html +++ b/content/mail.html @@ -190,6 +190,25 @@ to unsubscribe someone you can email: {listname}-unsubscribe-badboy=menace@tlp.apache.org +Unsubscribe from the Users mailing list + + +function generate(form) { + var badBoy=form[0]; + var email = 'user-unsubscribe-' + badBoy.value.replace('@', '=') + '@struts.apache.org'; + var link = document.getElementById('ready-email'); + link.style.visibility = 'visible'; + link.href = 'mailto:' + email; +} + + + +Paste user email address + + +Unsubscribe + + Guidelines Mailing lists provide a simple and effective communication mechanism. With potentially thousands of subscribers, there
[struts-site] 01/01: Merge pull request #175 from apache/WW-4173-disable
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts-site.git commit be3650df95452a85d8f34e3e51aebe94492e3847 Merge: fbe33ec48 1b1d06061 Author: Lukasz Lenart AuthorDate: Wed Oct 26 09:33:17 2022 +0200 Merge pull request #175 from apache/WW-4173-disable WW-4173 Adds note about how to disable interceptor .asf.yaml | 11 +++ source/core-developers/interceptors.md | 29 + source/mail.md | 19 +++ 3 files changed, 51 insertions(+), 8 deletions(-)
[struts-site] branch master updated (fbe33ec48 -> be3650df9)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/struts-site.git from fbe33ec48 Merge pull request #174 from apache/separator add 35061d6e5 WW-4173 Adds note about how to disable interceptor add ffd50682e Adds notifications to be sent to proper lists add 1b1d06061 Adds helper to prepare unsubscribe email new be3650df9 Merge pull request #175 from apache/WW-4173-disable The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .asf.yaml | 11 +++ source/core-developers/interceptors.md | 29 + source/mail.md | 19 +++ 3 files changed, 51 insertions(+), 8 deletions(-)
[struts-site] branch asf-site updated: Automatic Site Publish by Buildbot
This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/struts-site.git The following commit(s) were added to refs/heads/asf-site by this push: new 7a982747d Automatic Site Publish by Buildbot 7a982747d is described below commit 7a982747d2c2d028076d12aee553959cbab6a3a8 Author: buildbot AuthorDate: Wed Oct 26 07:33:50 2022 + Automatic Site Publish by Buildbot --- output/core-developers/interceptors.html | 44 +++--- output/mail.html | 19 ++ output/tag-developers/a-tag.html | 16 output/tag-developers/actionerror-tag.html | 16 output/tag-developers/actionmessage-tag.html | 16 output/tag-developers/checkbox-tag.html| 16 output/tag-developers/checkboxlist-tag.html| 16 output/tag-developers/combobox-tag.html| 16 output/tag-developers/component-tag.html | 16 output/tag-developers/datetextfield-tag.html | 16 output/tag-developers/doubleselect-tag.html| 16 output/tag-developers/fielderror-tag.html | 16 output/tag-developers/file-tag.html| 16 output/tag-developers/form-tag.html| 16 output/tag-developers/head-tag.html| 16 output/tag-developers/hidden-tag.html | 16 output/tag-developers/inputtransferselect-tag.html | 16 output/tag-developers/label-tag.html | 16 .../tag-developers/optiontransferselect-tag.html | 16 output/tag-developers/password-tag.html| 16 output/tag-developers/radio-tag.html | 16 output/tag-developers/reset-tag.html | 16 output/tag-developers/select-tag.html | 16 output/tag-developers/submit-tag.html | 16 output/tag-developers/textarea-tag.html| 16 output/tag-developers/textfield-tag.html | 16 output/tag-developers/token-tag.html | 16 output/tag-developers/updownselect-tag.html| 16 28 files changed, 49 insertions(+), 430 deletions(-) diff --git a/output/core-developers/interceptors.html b/output/core-developers/interceptors.html index d5bf0a9cc..0e6587bcd 100644 --- a/output/core-developers/interceptors.html +++ b/output/core-developers/interceptors.html @@ -141,6 +141,7 @@ Interceptor Parameter Overriding Interceptor Parameter Overriding Inheritance Lazy parameters + Disabling interceptor Order of Interceptor Execution @@ -167,7 +168,7 @@ is pluggable, so you can decide exactly which features an Action needs to suppor the Interceptors bundled with the framework. Interceptors “set the stage” for the Action classes, doing much of the “heavy lifting” before the Action executes. -Action Lifecyle +Action Lifecycle @@ -773,7 +774,7 @@ than reiterate the same list of Interceptors, we can bundle these Interceptors t -Since the struts-default.xml is included in the application’s configuration by default, all of the predefined +Since the struts-default.xml is included in the application’s configuration by default, all the predefined interceptors and stacks are available “out of the box”. Framework Interceptors @@ -1103,7 +1104,7 @@ the other params will be null. This functionality was added in Struts 2.5.9 It is possible to define an interceptor with parameters evaluated during action invocation. In such case -the interceptor must be marked with WithLazyParams interface. This must be developer’s decision as interceptor +the interceptor must be marked with WithLazyParams interface. This must be developer’s decision as interceptor must be aware of having those parameters set during invocation and not when the interceptor is created as it happens in normal way. @@ -1117,23 +1118,38 @@ in normal way. -public class MockLazyInterceptor extends AbstractInterceptor implements WithLazyParams { +public class MockLazyInterceptor extends AbstractInterceptor implements WithLazyParams { -private String foo = ""; +private String foo = ""; -public void setFoo(String foo) { -this.foo = foo; -} +public void setFoo(String foo) { +this.foo = foo; +} -public String intercept(ActionInvocation invocation) throws Exception { - -return invocation.invoke(); -} -} +public String intercept(ActionInvocation invocation) throws Exception { + +return invocation.invoke(); +} +} Please be aware that order of interceptors can matter when want to access parameters passed via request as those -parameters are set by P
[struts-site] branch asf-staging updated: Updates stage by Jenkins
This is an automated email from the ASF dual-hosted git repository. git-site-role pushed a commit to branch asf-staging in repository https://gitbox.apache.org/repos/asf/struts-site.git The following commit(s) were added to refs/heads/asf-staging by this push: new f8a48129a Updates stage by Jenkins f8a48129a is described below commit f8a48129a21b33927ff0403b0ece755d761cebbb Author: jenkins AuthorDate: Wed Oct 26 07:35:08 2022 + Updates stage by Jenkins
[struts] branch WW-4692-encoder-decoder updated: WW-4692 Removes code smells reported by Sonar and adds additional test case
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-4692-encoder-decoder in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/WW-4692-encoder-decoder by this push: new d399d3220 WW-4692 Removes code smells reported by Sonar and adds additional test case d399d3220 is described below commit d399d3220c5507a27f5b22ff42075e50dfe864cf Author: Lukasz Lenart AuthorDate: Wed Oct 26 10:38:20 2022 +0200 WW-4692 Removes code smells reported by Sonar and adds additional test case --- .../org/apache/struts2/url/StrutsUrlDecoder.java | 2 +- .../struts2/views/util/DefaultUrlHelper.java | 8 +-- .../apache/struts2/url/StrutsUrlEncoderTest.java | 60 ++ 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java index 752055154..f3ae7d0c4 100644 --- a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java +++ b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java @@ -83,7 +83,7 @@ public class StrutsUrlDecoder implements UrlDecoder { if (ix + 2 > len) { throw new IllegalArgumentException("The % character must be followed by two hexademical digits"); } -b = (byte) ((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++])); +b = (byte) ((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++]) & 0xff ); } bytes[ox++] = b; } diff --git a/core/src/main/java/org/apache/struts2/views/util/DefaultUrlHelper.java b/core/src/main/java/org/apache/struts2/views/util/DefaultUrlHelper.java index d888ecfea..9f383c611 100644 --- a/core/src/main/java/org/apache/struts2/views/util/DefaultUrlHelper.java +++ b/core/src/main/java/org/apache/struts2/views/util/DefaultUrlHelper.java @@ -251,8 +251,8 @@ public class DefaultUrlHelper implements UrlHelper { } private String buildParameterSubstring(String name, String value, boolean encode) { -String encodedName = encode ? encode(name) : name; -String encodedValue = encode ? encode(value) : value; +String encodedName = encode ? encoder.encode(name) : name; +String encodedValue = encode ? encoder.encode(value) : value; return encodedName + '=' + encodedValue; } @@ -309,8 +309,8 @@ public class DefaultUrlHelper implements UrlHelper { paramValue = tmpParams[1]; } if (paramName != null) { -paramName = decode(paramName, true); -String translatedParamValue = decode(paramValue, true); +paramName = decoder.decode(paramName, true); +String translatedParamValue = decoder.decode(paramValue, true); if (queryParams.containsKey(paramName) || forceValueArray) { // WW-1619 append new param value to existing value(s) diff --git a/core/src/test/java/org/apache/struts2/url/StrutsUrlEncoderTest.java b/core/src/test/java/org/apache/struts2/url/StrutsUrlEncoderTest.java new file mode 100644 index 0..9ca04f0e3 --- /dev/null +++ b/core/src/test/java/org/apache/struts2/url/StrutsUrlEncoderTest.java @@ -0,0 +1,60 @@ +package org.apache.struts2.url; + +import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class StrutsUrlEncoderTest { + +private StrutsUrlEncoder encoder; + +@Test +public void testEncodeValidIso88591Start() { +String result = encoder.encode("%", "ISO-8859-1"); +assertEquals("%25", result); +} + +@Test +public void testEncodeValidIso88591Middle() { +String result = encoder.encode("xx%xx", "ISO-8859-1"); +assertEquals("xx%25xx", result); +} + +@Test +public void testEncodeValidIso88591End() { +String result = encoder.encode("%", "ISO-8859-1"); +assertEquals("%25", result); +} + +@Test +public void testEncodeValidUtf8Start() { +String result = encoder.encode("\u00ea", "UTF-8"); +assertEquals("%C3%AA", result); +} + +@Test +public void testEncodeValidUtf8Middle() { +String result = encoder.encode("xx\u00eaxx", "UTF-8"); +assertEquals("xx%C3%AAxx", result); +} + +@Test +public void testEncodeValidUtf8End() { +String result = encoder.encode("\u00ea", "UTF-8"); +assertEquals("%C3%AA", result); +} + +@Test +public void testEncodePlusCharAsSpace() { +String result = encoder.encode("a b", "UTF-8"); +assertEquals("a+b", result); +} + +@Before +public void s
[struts] branch WW-4692-encoder-decoder updated: WW-4692 Adds missing header with license
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-4692-encoder-decoder in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/WW-4692-encoder-decoder by this push: new 520c8c6a1 WW-4692 Adds missing header with license 520c8c6a1 is described below commit 520c8c6a1b21c9dbbd346ee59d2bf4188d6044b0 Author: Lukasz Lenart AuthorDate: Wed Oct 26 10:46:41 2022 +0200 WW-4692 Adds missing header with license --- .../org/apache/struts2/url/StrutsUrlEncoderTest.java | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/apache/struts2/url/StrutsUrlEncoderTest.java b/core/src/test/java/org/apache/struts2/url/StrutsUrlEncoderTest.java index 9ca04f0e3..d095f0291 100644 --- a/core/src/test/java/org/apache/struts2/url/StrutsUrlEncoderTest.java +++ b/core/src/test/java/org/apache/struts2/url/StrutsUrlEncoderTest.java @@ -1,6 +1,23 @@ +/* + * 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.url; -import junit.framework.TestCase; import org.junit.Before; import org.junit.Test;
[struts] branch WW-4692-encoder-decoder updated: WW-4692 Prevents int promotion behaviour
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-4692-encoder-decoder in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/WW-4692-encoder-decoder by this push: new 70f76d3cb WW-4692 Prevents int promotion behaviour 70f76d3cb is described below commit 70f76d3cb56052617a3b7ab51c1f399aec5f0cc3 Author: Lukasz Lenart AuthorDate: Wed Oct 26 11:21:16 2022 +0200 WW-4692 Prevents int promotion behaviour --- core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java index f3ae7d0c4..5b2ad73da 100644 --- a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java +++ b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java @@ -81,9 +81,9 @@ public class StrutsUrlDecoder implements UrlDecoder { b = (byte) ' '; } else if (b == '%') { if (ix + 2 > len) { -throw new IllegalArgumentException("The % character must be followed by two hexademical digits"); +throw new IllegalArgumentException("The % character must be followed by two hexadecimal digits"); } -b = (byte) ((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++]) & 0xff ); +b = (byte) (((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++])) & 0xff); } bytes[ox++] = b; }
[struts] branch WW-4692-encoder-decoder updated (70f76d3cb -> 813e938f8)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch WW-4692-encoder-decoder in repository https://gitbox.apache.org/repos/asf/struts.git from 70f76d3cb WW-4692 Prevents int promotion behaviour new 5ecabf810 WW-4692 Drops unused imports new 813e938f8 WW-4692 Fixes int promotion behaviour The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../StrutsDefaultConfigurationProvider.java| 209 ++--- .../config/AbstractBeanSelectionProvider.java | 1 - .../org/apache/struts2/url/StrutsUrlDecoder.java | 2 +- 3 files changed, 104 insertions(+), 108 deletions(-)
[struts] 02/02: WW-4692 Fixes int promotion behaviour
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-4692-encoder-decoder in repository https://gitbox.apache.org/repos/asf/struts.git commit 813e938f88a7f48e72924f6d8dbb5efdbcc5538d Author: Lukasz Lenart AuthorDate: Wed Oct 26 11:42:23 2022 +0200 WW-4692 Fixes int promotion behaviour --- core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java index 5b2ad73da..3a480d87f 100644 --- a/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java +++ b/core/src/main/java/org/apache/struts2/url/StrutsUrlDecoder.java @@ -83,7 +83,7 @@ public class StrutsUrlDecoder implements UrlDecoder { if (ix + 2 > len) { throw new IllegalArgumentException("The % character must be followed by two hexadecimal digits"); } -b = (byte) (((convertHexDigit(bytes[ix++]) << 4) + convertHexDigit(bytes[ix++])) & 0xff); +b = (byte) convertHexDigit(bytes[ix++]) << 4) & 0xff) + convertHexDigit(bytes[ix++]) & 0xff) & 0xff); } bytes[ox++] = b; }
[struts] 01/02: WW-4692 Drops unused imports
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-4692-encoder-decoder in repository https://gitbox.apache.org/repos/asf/struts.git commit 5ecabf810319c431e9de5f0af90bf33529dc8f60 Author: Lukasz Lenart AuthorDate: Wed Oct 26 11:42:07 2022 +0200 WW-4692 Drops unused imports --- .../StrutsDefaultConfigurationProvider.java| 209 ++--- .../config/AbstractBeanSelectionProvider.java | 1 - 2 files changed, 103 insertions(+), 107 deletions(-) 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 7c0a80165..2ac045d45 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 @@ -21,26 +21,16 @@ package com.opensymphony.xwork2.config.providers; import com.opensymphony.xwork2.ActionProxyFactory; import com.opensymphony.xwork2.DefaultActionProxyFactory; import com.opensymphony.xwork2.DefaultLocaleProviderFactory; -import com.opensymphony.xwork2.LocaleProviderFactory; -import com.opensymphony.xwork2.StrutsTextProviderFactory; -import com.opensymphony.xwork2.TextProviderFactory; -import com.opensymphony.xwork2.factory.DefaultUnknownHandlerFactory; -import com.opensymphony.xwork2.factory.UnknownHandlerFactory; -import com.opensymphony.xwork2.ognl.BeanInfoCacheFactory; -import com.opensymphony.xwork2.ognl.ExpressionCacheFactory; -import com.opensymphony.xwork2.ognl.accessor.HttpParametersPropertyAccessor; -import com.opensymphony.xwork2.ognl.accessor.ParameterPropertyAccessor; -import com.opensymphony.xwork2.security.AcceptedPatternsChecker; -import com.opensymphony.xwork2.security.DefaultAcceptedPatternsChecker; -import com.opensymphony.xwork2.security.DefaultExcludedPatternsChecker; import com.opensymphony.xwork2.DefaultTextProvider; import com.opensymphony.xwork2.DefaultUnknownHandlerManager; -import com.opensymphony.xwork2.security.DefaultNotExcludedAcceptedPatternsChecker; -import com.opensymphony.xwork2.security.ExcludedPatternsChecker; import com.opensymphony.xwork2.FileManager; import com.opensymphony.xwork2.FileManagerFactory; +import com.opensymphony.xwork2.LocaleProviderFactory; +import com.opensymphony.xwork2.LocalizedTextProvider; import com.opensymphony.xwork2.ObjectFactory; +import com.opensymphony.xwork2.StrutsTextProviderFactory; import com.opensymphony.xwork2.TextProvider; +import com.opensymphony.xwork2.TextProviderFactory; import com.opensymphony.xwork2.UnknownHandlerManager; import com.opensymphony.xwork2.config.Configuration; import com.opensymphony.xwork2.config.ConfigurationException; @@ -57,14 +47,7 @@ import com.opensymphony.xwork2.conversion.impl.CollectionConverter; 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; -import org.apache.struts2.conversion.StrutsTypeConverterHolder; import com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler; import com.opensymphony.xwork2.conversion.impl.NumberConverter; import com.opensymphony.xwork2.conversion.impl.StringConverter; @@ -73,34 +56,45 @@ import com.opensymphony.xwork2.conversion.impl.XWorkConverter; import com.opensymphony.xwork2.factory.ActionFactory; import com.opensymphony.xwork2.factory.ConverterFactory; import com.opensymphony.xwork2.factory.DefaultActionFactory; -import com.opensymphony.xwork2.factory.StrutsConverterFactory; import com.opensymphony.xwork2.factory.DefaultInterceptorFactory; import com.opensymphony.xwork2.factory.DefaultResultFactory; +import com.opensymphony.xwork2.factory.DefaultUnknownHandlerFactory; import com.opensymphony.xwork2.factory.InterceptorFactory; import com.opensymphony.xwork2.factory.ResultFactory; +import com.opensymphony.xwork2.factory.StrutsConverterFactory; +import com.opensymphony.xwork2.factory.UnknownHandlerFactory; import com.opensymphony.xwork2.inject.ContainerBuilder; import com.opensymphony.xwork2.inject.Scope; +import com.opensymphony.xwork2.ognl.BeanInfoCacheFactory; +import com.opensymphony.xwork2.ognl.DefaultOgnlBeanInfoCacheFactory; +import com.opensymphony.xwork2.ognl.Defaul
[struts] branch WW-4692-encoder-decoder updated: WW-4692 Improves code coverage
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch WW-4692-encoder-decoder in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/WW-4692-encoder-decoder by this push: new 6e6c95f6e WW-4692 Improves code coverage 6e6c95f6e is described below commit 6e6c95f6e9dce083fb5448338e31501303766f61 Author: Lukasz Lenart AuthorDate: Wed Oct 26 13:53:58 2022 +0200 WW-4692 Improves code coverage --- .../apache/struts2/url/StrutsUrlDecoderTest.java | 48 ++ .../apache/struts2/url/StrutsUrlEncoderTest.java | 13 ++ 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/core/src/test/java/org/apache/struts2/url/StrutsUrlDecoderTest.java b/core/src/test/java/org/apache/struts2/url/StrutsUrlDecoderTest.java index cc26e3e2a..5dd44f897 100644 --- a/core/src/test/java/org/apache/struts2/url/StrutsUrlDecoderTest.java +++ b/core/src/test/java/org/apache/struts2/url/StrutsUrlDecoderTest.java @@ -22,6 +22,7 @@ import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; public class StrutsUrlDecoderTest { @@ -29,11 +30,11 @@ public class StrutsUrlDecoderTest { private StrutsUrlDecoder decoder; @Test -public void testURLDecodeStringInvalid() { +public void testDecodeStringInvalid() { // %n rather than %nn should throw an IAE according to the Javadoc Exception exception = null; try { -this.decoder.decode("%5x", "ISO-8859-1", false); +decoder.decode("%5x", "ISO-8859-1", false); } catch (Exception e) { exception = e; } @@ -42,7 +43,7 @@ public class StrutsUrlDecoderTest { // Edge case trying to trigger ArrayIndexOutOfBoundsException exception = null; try { -this.decoder.decode("%5", "ISO-8859-1", false); +decoder.decode("%5", "ISO-8859-1", false); } catch (Exception e) { exception = e; } @@ -50,47 +51,60 @@ public class StrutsUrlDecoderTest { } @Test -public void testURLDecodeStringValidIso88591Start() { -String result = this.decoder.decode("%41", "ISO-8859-1", false); +public void testDecodeStringValidIso88591Start() { +String result = decoder.decode("%41", "ISO-8859-1", false); assertEquals("A", result); } @Test -public void testURLDecodeStringValidIso88591Middle() { -String result = this.decoder.decode("xx%41xx", "ISO-8859-1", false); +public void testDecodeStringValidIso88591Middle() { +String result = decoder.decode("xx%41xx", "ISO-8859-1", false); assertEquals("xxAxx", result); } @Test -public void testURLDecodeStringValidIso88591End() { -String result = this.decoder.decode("%41", "ISO-8859-1", false); +public void testDecodeStringValidIso88591End() { +String result = decoder.decode("%41", "ISO-8859-1", false); assertEquals("A", result); } @Test -public void testURLDecodeStringValidUtf8Start() { -String result = this.decoder.decode("%c3%aa", "UTF-8", false); +public void testDecodeStringValidUtf8Start() { +String result = decoder.decode("%c3%aa", "UTF-8", false); assertEquals("\u00ea", result); } @Test -public void testURLDecodeStringValidUtf8Middle() { -String result = this.decoder.decode("xx%c3%aaxx", "UTF-8", false); +public void testDecodeStringValidUtf8Middle() { +String result = decoder.decode("xx%c3%aaxx", "UTF-8", false); assertEquals("xx\u00eaxx", result); } @Test -public void testURLDecodeStringValidUtf8End() { -String result = this.decoder.decode("%c3%aa", "UTF-8", false); +public void testDecodeStringValidUtf8End() { +String result = decoder.decode("%c3%aa", "UTF-8", false); assertEquals("\u00ea", result); } @Test -public void testURLDecodePlusCharAsSpace() { -String result = this.decoder.decode("a+b", "UTF-8", true); +public void testDecodePlusCharAsSpace() { +String result = decoder.decode("a+b", "UTF-8", true); assertEquals("a b", result); } +@Test +public void testDecodeNull() { +String result = decoder.decode(null); +assertNull(result); +} + +@Test +public void testSettingEncoding() { +decoder.setEncoding("ISO-8859-1"); +String result = decoder.decode("%41"); +assertEquals("A", result); +} + @Before public void setUp() throws Exception { this.decoder = new StrutsUrlDecoder(); diff --git a/core/src/test/java/org/apache/struts2/url/StrutsUrlEncoderTest.java b/core/src/test/java/org/