Lukasz Lenart created WW-5871:
---------------------------------
Summary: 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
Fix For: 7.6.0
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)