Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master 2024-06-10 #963

Merged
merged 63 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
ac409d6
Bump org.apache.maven.plugins:maven-failsafe-plugin
dependabot[bot] Apr 8, 2024
ccd5f5d
Bump asm.version from 9.6 to 9.7
dependabot[bot] Apr 8, 2024
268ed78
Bump org.assertj:assertj-core from 3.25.2 to 3.25.3
dependabot[bot] Apr 8, 2024
758174c
WW-5400 Extend default configuration options for the CSP interceptor.
eschulma Apr 10, 2024
0151bde
WW-5400 Better toString formatting
eschulma Apr 11, 2024
6ac8b04
WW-5400 Added @since Struts 6.5.0 to new properties as requested
eschulma Apr 12, 2024
efdaf7e
Merge pull request #909 from apache/dependabot/maven/org.assertj-asse…
lukaszlenart Apr 20, 2024
b2b35f0
Bump org.codehaus.mojo:versions-maven-plugin from 2.16.1 to 2.16.2
dependabot[bot] Apr 22, 2024
856d980
Bump actions/upload-artifact from 4.3.1 to 4.3.2
dependabot[bot] Apr 22, 2024
eca5b21
Merge pull request #923 from apache/dependabot/github_actions/actions…
lukaszlenart Apr 22, 2024
3cde668
Merge pull request #922 from apache/dependabot/maven/org.codehaus.moj…
lukaszlenart Apr 22, 2024
a88cb74
WW-5419 Fixes support for loading Tiles definitions
lukaszlenart Apr 21, 2024
36275b9
WW-5420 Upgrades commons-text to ver. 1.12.0
lukaszlenart Apr 25, 2024
c1c6a46
Bump org.codehaus.mojo:exec-maven-plugin from 3.1.0 to 3.2.0
dependabot[bot] Apr 29, 2024
2d9af47
Bump actions/upload-artifact from 4.3.2 to 4.3.3
dependabot[bot] Apr 29, 2024
5cd9356
Merge pull request #925 from apache/dependabot/maven/org.codehaus.moj…
lukaszlenart Apr 29, 2024
ed3786c
Merge pull request #926 from apache/dependabot/github_actions/actions…
lukaszlenart Apr 29, 2024
3ed212a
Merge pull request #907 from apache/dependabot/maven/asm.version-9.7
lukaszlenart Apr 29, 2024
f2e93d0
Merge pull request #905 from apache/dependabot/maven/org.apache.maven…
lukaszlenart Apr 29, 2024
c0d1217
Merge pull request #924 from apache/feature/WW-5420-text
lukaszlenart Apr 29, 2024
49b8eed
Merge pull request #920 from apache/fix/WW-5419-tiles
lukaszlenart May 6, 2024
649760d
Merge pull request #913 from eschulma/master
lukaszlenart May 11, 2024
4dfbe09
WW-5414 Always call afterInvocation even in case of exception
lukaszlenart May 11, 2024
b36e88f
WW-5415 Fixes accessing public constructors via expression
lukaszlenart May 12, 2024
942fbd6
Bump org.apache.maven.plugins:maven-source-plugin from 3.3.0 to 3.3.1
dependabot[bot] May 13, 2024
c6b53d4
Bump slf4j.version from 2.0.12 to 2.0.13
dependabot[bot] May 13, 2024
6e12c25
Bump org.apache.maven.plugins:maven-project-info-reports-plugin
dependabot[bot] May 13, 2024
039c5f8
Bump ossf/scorecard-action from 2.3.1 to 2.3.3
dependabot[bot] May 13, 2024
7c523ac
WW-5415 Constructor members should be exempted as static members
kusalk May 13, 2024
f338fda
Merge pull request #934 from apache/dependabot/maven/org.apache.maven…
lukaszlenart May 13, 2024
73be382
Merge pull request #936 from apache/dependabot/maven/slf4j.version-2.…
lukaszlenart May 13, 2024
03126c0
Merge pull request #938 from apache/dependabot/maven/org.apache.maven…
lukaszlenart May 13, 2024
195b0e5
Merge pull request #939 from apache/dependabot/github_actions/ossf/sc…
lukaszlenart May 13, 2024
0a57cac
WW-5422 Adds dedicate unit test to cover DefaultLocaleProvider
lukaszlenart May 11, 2024
49eda37
Merge pull request #931 from apache/fix/WW-5422-trimable
lukaszlenart May 13, 2024
d147543
Merge pull request #932 from apache/feature/WW-5414-after
lukaszlenart May 14, 2024
40ccc74
Merge pull request #933 from apache/fix/WW-5415-constructor
lukaszlenart May 14, 2024
19252ad
Bump org.jacoco:jacoco-maven-plugin from 0.8.11 to 0.8.12
dependabot[bot] May 20, 2024
ab89b82
Bump jackson.version from 2.16.1 to 2.17.1
dependabot[bot] May 20, 2024
9ee39d0
INFRA-25666 Disables review by code owners
lukaszlenart May 20, 2024
36230dc
Merge pull request #945 from apache/fix/disable-review
lukaszlenart May 20, 2024
8268d0b
Merge pull request #940 from apache/dependabot/maven/org.jacoco-jacoc…
lukaszlenart Jun 1, 2024
9682b3b
Merge pull request #944 from apache/dependabot/maven/jackson.version-…
lukaszlenart Jun 1, 2024
4a8ff99
WW-5424 Fixes ClassCastException when using short var name in s:set tag
lukaszlenart Jun 2, 2024
00752e3
Disables required reviewers option
lukaszlenart Jun 2, 2024
855b95e
WW-5412 Upgrades struts-master to ver 15
lukaszlenart Jun 2, 2024
e5fcc8f
Bump org.apache.maven.plugins:maven-assembly-plugin from 3.6.0 to 3.7.1
dependabot[bot] Jun 3, 2024
5c2be7c
Bump org.freemarker:freemarker from 2.3.32 to 2.3.33
dependabot[bot] Jun 3, 2024
f6b25ac
Merge pull request #950 from apache/dependabot/maven/org.apache.maven…
lukaszlenart Jun 3, 2024
ee040ba
Merge pull request #953 from apache/dependabot/maven/org.freemarker-f…
lukaszlenart Jun 3, 2024
0cdce05
Merge pull request #946 from apache/fix/WW-5424-class-cast-exception
lukaszlenart Jun 5, 2024
a25173f
Merge pull request #947 from apache/fix/no-reviewers-required
lukaszlenart Jun 5, 2024
dcaff0b
Merge pull request #948 from apache/feature/WW-5412-master
lukaszlenart Jun 5, 2024
3a6ad5a
WW-5400 Simplifies how CspSettings is created
lukaszlenart Jun 5, 2024
4a05653
Removes duplication
lukaszlenart Jun 6, 2024
03db4f1
WW-5250 Addresses TODO in test and stops using Mock Objects
lukaszlenart Jun 7, 2024
86b14c7
Bump org.apache.commons:commons-compress from 1.26.0 to 1.26.2
dependabot[bot] Jun 10, 2024
9133d24
Bump org.owasp:dependency-check-maven from 8.4.2 to 9.2.0
dependabot[bot] Jun 10, 2024
de2a8d9
Merge pull request #961 from apache/dependabot/maven/org.apache.commo…
lukaszlenart Jun 10, 2024
cabc076
Merge pull request #962 from apache/dependabot/maven/org.owasp-depend…
lukaszlenart Jun 10, 2024
cf34f0d
Merge pull request #956 from apache/feature/WW-5400-refactor
lukaszlenart Jun 10, 2024
444e4d4
Merge pull request #957 from apache/fix/WW-5250-todo
lukaszlenart Jun 10, 2024
28ea6d0
Merge branch 'master' into merge/master-2024-06-10
lukaszlenart Jun 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ github:
contexts:
- build
required_pull_request_reviews:
require_code_owner_reviews: true
required_approving_review_count: 1
# it does not work because our github teams are private/secret, see INFRA-25666
require_code_owner_reviews: false
required_approving_review_count: 0
autolink_jira:
- WW
dependabot_alerts: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scorecards-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # 2.3.1
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # 2.3.3
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -58,7 +58,7 @@ jobs:
publish_results: true

- name: "Upload artifact"
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # 4.3.1
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # 4.3.3
with:
name: SARIF file
path: results.sarif
Expand Down
2 changes: 1 addition & 1 deletion apps/showcase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M6</version>
<version>3.2.5</version>
<configuration>
<includes>
<include>it.org.apache.struts2.showcase.*Test</include>
Expand Down
2 changes: 1 addition & 1 deletion assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<version>3.7.1</version>
<executions>
<execution>
<id>make-assembly</id>
Expand Down
6 changes: 6 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/com/opensymphony/xwork2/ActionSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public boolean isValidLocale(Locale locale) {
return getLocaleProvider().isValidLocale(locale);
}

@Override
public Locale toLocale(String localeStr) {
return getLocaleProvider().toLocale(localeStr);
}

@Override
public boolean hasKey(String key) {
return getTextProvider().hasKey(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,23 @@ public Locale getLocale() {

@Override
public boolean isValidLocaleString(String localeStr) {
Locale locale = this.toLocale(localeStr);
return isValidLocale(locale);
}

@Override
public boolean isValidLocale(Locale locale) {
return locale != null && LocaleUtils.isAvailableLocale(locale);
}

@Override
public Locale toLocale(String localeStr) {
Locale locale = null;
try {
locale = LocaleUtils.toLocale(StringUtils.trimToNull(localeStr));
} catch (IllegalArgumentException e) {
LOG.warn(new ParameterizedMessage("Cannot convert [{}] to proper locale", localeStr), e);
}
return isValidLocale(locale);
}

@Override
public boolean isValidLocale(Locale locale) {
return LocaleUtils.isAvailableLocale(locale);
return locale;
}
}
16 changes: 16 additions & 0 deletions core/src/main/java/com/opensymphony/xwork2/LocaleProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package com.opensymphony.xwork2;

import org.apache.commons.lang3.LocaleUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.Locale;


Expand Down Expand Up @@ -58,4 +61,17 @@ public interface LocaleProvider {
*/
boolean isValidLocale(Locale locale);

/**
* Tries to convert provided locale string into {@link Locale} or returns null
* @param localeStr a String representing locale, e.g.: en_EN
* @return instance of {@link Locale} or null
* @since Struts 6.5.0
*/
default Locale toLocale(String localeStr) {
try {
return LocaleUtils.toLocale(StringUtils.trimToNull(localeStr));
} catch (IllegalArgumentException e) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.struts2.ognl.ThreadAllowlist;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
Expand Down Expand Up @@ -147,11 +148,11 @@ public boolean isAccessible(Map context, Object target, Member member, String pr
if (target != null) {
// Special case: Target is a Class object but not Class.class
if (Class.class.equals(target.getClass()) && !Class.class.equals(target)) {
if (!isStatic(member)) {
throw new IllegalArgumentException("Member expected to be static!");
if (!isStatic(member) && !Constructor.class.equals(member.getClass())) {
throw new IllegalArgumentException("Member expected to be static or constructor!");
}
if (!member.getDeclaringClass().equals(target)) {
throw new IllegalArgumentException("Target class does not match static member!");
throw new IllegalArgumentException("Target class does not match member!");
}
target = null; // This information is not useful to us and conflicts with following logic which expects target to be null or an instance containing the member
// Standard case: Member should exist on target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface ActionValidatorManager {
* @param method the name of the method being invoked on the action - can be <tt>null</tt>.
* @return a list of all validators for the given class and context.
*/
List<Validator> getValidators(Class clazz, String context, String method);
List<Validator> getValidators(Class<?> clazz, String context, String method);

/**
* Returns a list of validators for the given class and context. This is the primary
Expand All @@ -46,7 +46,7 @@ public interface ActionValidatorManager {
* @param context the context of the action class - can be <tt>null</tt>.
* @return a list of all validators for the given class and context.
*/
List<Validator> getValidators(Class clazz, String context);
List<Validator> getValidators(Class<?> clazz, String context);

/**
* Validates the given object using action and its context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void validate(Object object, String context, ValidatorContext validatorCo
* @param context context
* @return a validator key which is the class name plus context.
*/
protected String buildValidatorKey(Class clazz, String context) {
protected String buildValidatorKey(Class<?> clazz, String context) {
return clazz.getName() + "/" + context;
}

Expand All @@ -137,7 +137,7 @@ protected Validator getValidatorFromValidatorConfig(ValidatorConfig config, Valu
}

@Override
public synchronized List<Validator> getValidators(Class clazz, String context, String method) {
public synchronized List<Validator> getValidators(Class<?> clazz, String context, String method) {
String validatorKey = buildValidatorKey(clazz, context);

if (!validatorCache.containsKey(validatorKey)) {
Expand All @@ -158,7 +158,7 @@ public synchronized List<Validator> getValidators(Class clazz, String context, S
}

@Override
public synchronized List<Validator> getValidators(Class clazz, String context) {
public synchronized List<Validator> getValidators(Class<?> clazz, String context) {
return getValidators(clazz, context, null);
}

Expand Down Expand Up @@ -277,7 +277,7 @@ public void validate(Object object, String context, ValidatorContext validatorCo
* @param checked the set of previously checked class-contexts, null if none have been checked
* @return a list of validator configs for the given class and context.
*/
protected List<ValidatorConfig> buildValidatorConfigs(Class clazz, String context, boolean checkFile, Set<String> checked) {
protected List<ValidatorConfig> buildValidatorConfigs(Class<?> clazz, String context, boolean checkFile, Set<String> checked) {
List<ValidatorConfig> validatorConfigs = new ArrayList<>();

if (checked == null) {
Expand All @@ -287,7 +287,7 @@ protected List<ValidatorConfig> buildValidatorConfigs(Class clazz, String contex
}

if (clazz.isInterface()) {
for (Class anInterface : clazz.getInterfaces()) {
for (Class<?> anInterface : clazz.getInterfaces()) {
validatorConfigs.addAll(buildValidatorConfigs(anInterface, context, checkFile, checked));
}
} else {
Expand All @@ -297,7 +297,7 @@ protected List<ValidatorConfig> buildValidatorConfigs(Class clazz, String contex
}

// look for validators for implemented interfaces
for (Class anInterface1 : clazz.getInterfaces()) {
for (Class<?> anInterface1 : clazz.getInterfaces()) {
if (checked.contains(anInterface1.getName())) {
continue;
}
Expand All @@ -317,17 +317,17 @@ protected List<ValidatorConfig> buildValidatorConfigs(Class clazz, String contex
return validatorConfigs;
}

protected List<ValidatorConfig> buildAliasValidatorConfigs(Class aClass, String context, boolean checkFile) {
protected List<ValidatorConfig> buildAliasValidatorConfigs(Class<?> aClass, String context, boolean checkFile) {
String fileName = aClass.getName().replace('.', '/') + "-" + context + VALIDATION_CONFIG_SUFFIX;
return loadFile(fileName, aClass, checkFile);
}

protected List<ValidatorConfig> buildClassValidatorConfigs(Class aClass, boolean checkFile) {
protected List<ValidatorConfig> buildClassValidatorConfigs(Class<?> aClass, boolean checkFile) {
String fileName = aClass.getName().replace('.', '/') + VALIDATION_CONFIG_SUFFIX;
return loadFile(fileName, aClass, checkFile);
}

protected List<ValidatorConfig> loadFile(String fileName, Class clazz, boolean checkFile) {
protected List<ValidatorConfig> loadFile(String fileName, Class<?> clazz, boolean checkFile) {
List<ValidatorConfig> retList = Collections.emptyList();

URL fileUrl = ClassLoaderUtil.getResource(fileName, clazz);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,15 @@ public boolean isValidLocale(Locale locale) {
return localeProvider.isValidLocale(locale);
}

@Override
public Locale toLocale(String localeStr) {
return localeProvider.toLocale(localeStr);
}

public boolean hasKey(String key) {
return textProvider.hasKey(key);
}

public String getText(String aTextName) {
return textProvider.getText(aTextName);
}
Expand Down Expand Up @@ -280,6 +285,11 @@ public boolean isValidLocaleString(String localeStr) {
public boolean isValidLocale(Locale locale) {
return getLocaleProvider().isValidLocale(locale);
}

@Override
public Locale toLocale(String localeStr) {
return getLocaleProvider().toLocale(localeStr);
}
}

/**
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/apache/struts2/components/Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ public boolean end(Writer writer, String body) {
body="";

if (DispatcherConstants.APPLICATION.equalsIgnoreCase(scope)) {
stack.setValue("#application['" + getVar() + "']", o);
stack.setValue(String.format("#application[\"%s\"]", getVar()), o);
} else if (DispatcherConstants.SESSION.equalsIgnoreCase(scope)) {
stack.setValue("#session['" + getVar() + "']", o);
stack.setValue(String.format("#session[\"%s\"]", getVar()), o);
} else if (DispatcherConstants.REQUEST.equalsIgnoreCase(scope)) {
stack.setValue("#request['" + getVar() + "']", o);
stack.setValue(String.format("#request[\"%s\"]", getVar()), o);
} else if (DispatcherConstants.PAGE.equalsIgnoreCase(scope)) {
stack.setValue("#attr['" + getVar() + "']", o, false);
stack.setValue(String.format("#attr[\"%s\"]", getVar()), o, false);
} else {
// Default scope is action. Note: The action scope handling also adds the var to the page scope.
stack.getContext().put(getVar(), o);
stack.setValue("#attr['" + getVar() + "']", o, false);
putInContext(o);
stack.setValue(String.format("#attr[\"%s\"]", getVar()), o, false);
}

return super.end(writer, body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.util.TextParseUtil;
import org.apache.commons.lang3.LocaleUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
Expand Down Expand Up @@ -85,7 +84,7 @@ public void setRequestCookieParameterName(String requestCookieParameterName) {
}

public void setLocaleStorage(String storageName) {
if (storageName == null || "".equals(storageName)) {
if (storageName == null || storageName.isEmpty()) {
this.storage = Storage.ACCEPT_LANGUAGE;
} else {
try {
Expand Down Expand Up @@ -169,27 +168,21 @@ protected LocaleHandler getLocaleHandler(ActionInvocation invocation) {
}

/**
* Creates a Locale object from the request param, which might
* be already a Local or a String
* Creates a Locale object from the request param
*
* @param requestedLocale the parameter from the request
* @return the Locale
* @return instance of {@link Locale} or null
*/
protected Locale getLocaleFromParam(Object requestedLocale) {
protected Locale getLocaleFromParam(String requestedLocale) {
LocaleProvider localeProvider = localeProviderFactory.createLocaleProvider();

Locale locale = null;
if (requestedLocale != null) {
if (requestedLocale instanceof Locale) {
locale = (Locale) requestedLocale;
} else {
String localeStr = requestedLocale.toString();
if (localeProvider.isValidLocaleString(localeStr)) {
locale = LocaleUtils.toLocale(localeStr);
} else {
locale = localeProvider.getLocale();
}
locale = localeProvider.toLocale(requestedLocale);
if (locale == null) {
locale = localeProvider.getLocale();
}

if (locale != null) {
LOG.debug("Found locale: {}", locale);
}
Expand Down Expand Up @@ -285,7 +278,7 @@ protected AcceptLanguageLocaleHandler(ActionInvocation invocation) {
@Override
@SuppressWarnings("rawtypes")
public Locale find() {
if (supportedLocale.size() > 0) {
if (!supportedLocale.isEmpty()) {
Enumeration locales = actionInvocation.getInvocationContext().getServletRequest().getLocales();
while (locales.hasMoreElements()) {
Locale locale = (Locale) locales.nextElement();
Expand Down
Loading
Loading