[
https://issues.apache.org/jira/browse/WW-5871?focusedWorklogId=1056796&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1056796
]
ASF GitHub Bot logged work on WW-5871:
--------------------------------------
Author: ASF GitHub Bot
Created on: 24/Nov/26 08:09
Start Date: 24/Nov/26 08:09
Worklog Time Spent: 10m
Work Description: lukaszlenart opened a new pull request, #2159:
URL: https://github.com/apache/struts/pull/2159
Relates to [WW-5871](https://issues.apache.org/jira/browse/WW-5871).
Follow-up to #2154.
## Why
#2154 fixed request parameters bound to `String` properties being trimmed.
The cause was a missing exclusion in
`XWorkBasicConverter.trimSurroundingWhitespace`. It went unnoticed because the
WW-3666 test called `convertValue` with a bare `String`, and a bare `String`
takes the early return, so the test never exercised the trim. A real request
sends `String[]`, which does reach the trim.
## What
`ParametersInterceptorWhitespaceTest` drives
`ParametersInterceptor.applyParameters` with `String[]` values, as a real
request does. It turns the `@StrutsParameter` gate on and pushes the action
onto the stack.
| Input | Target | Expected |
|---|---|---|
| `" summer2026 "` | `String`, `CharSequence`, `Object`, `String[]`,
`List<String>`, `indexed[0]`, `attributes['key']` | kept untrimmed |
| `" 42 "`, `" 7 "`, `" true "`, `{" 1 ", " 2 "}` | `Integer`, `int`,
`Boolean`, `List<Integer>` | trimmed, then converted, with no conversion error |
| `" abc "` | `Integer` | conversion error reported |
| `""` or `" "` | boxed `Boolean` | `null` |
Every test also checks the conversion errors from the interceptor's own
context. An unannotated canary property must stay unbound.
## Verified
- Passes on `main`.
- On `STRUTS_7_5_0`, `testStringTargetsKeepSurroundingWhitespace` fails with
`" summer2026 "` → `"summer2026"`. It passes once #2154 is cherry-picked.
- Mutation probes: binding a detached `ActionContext` fails the
conversion-error test, and turning `requireAnnotations` off fails the canary
check.
## Note on the boxed Boolean cases
These two tests pin current behaviour. On `STRUTS_7_4_0` the same request
values for `""` and blank gave `false`, not `null`. Whether 7.5.1 restores
`false` is still open. If it does, these two assertions flip.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 1056796)
Time Spent: 40m (was: 0.5h)
> Request parameters bound to String properties are trimmed since 7.5.0
> ---------------------------------------------------------------------
>
> Key: WW-5871
> URL: https://issues.apache.org/jira/browse/WW-5871
> Project: Struts 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 7.5.0
> Reporter: Lukasz Lenart
> Priority: Major
> Fix For: 7.5.1
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> WW-3666 trims surrounding whitespace before converting a value to a
> non-String type, and String targets are meant to keep the raw value. Since
> 7.5.0, however, a request parameter bound to a String property is trimmed too.
> A request parameter reaches {{XWorkBasicConverter.convertValue}} as a
> {{String[]}}. The early return skips conversion only when the value's class
> already matches the target type, so a {{String[]}} passes it. The trim step
> then trims every element, because it excludes arrays, collections and
> Character targets but not String, and the trimmed element is converted to
> String.
> {code:java}
> converter.convertValue(context, null, null, null, new String[]{" summer2026
> "}, String.class);
> // 7.4.0: " summer2026 "
> // 7.5.0: "summer2026"
> converter.convertValue(context, null, null, null, " summer2026 ",
> String.class);
> // " summer2026 " on both - the early return covers a bare String
> {code}
> The test added with WW-3666 covers only the bare String case, which never
> reaches the trim.
> Impact: any String property loses leading and trailing whitespace, for
> example a password that starts or ends with a space no longer matches after
> the upgrade.
> Reported on the user list.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)