configured/discovered type converters shouldn't take presidence over
@Validate(converter)
-----------------------------------------------------------------------------------------
Key: STS-610
URL: http://www.stripesframework.org/jira/browse/STS-610
Project: Stripes
Issue Type: Bug
Components: Validation
Affects Versions: Release 1.5
Environment: SuSE 11.0, Tomcat 6.0.18, JDK 1.6.0_07
Reporter: Jacob Champlin
In 1.5 configured default type converters take presidence over the
@Validate(converter).
I believe this to be the wrong behavior, I think if you are explicit in the
Validate method then you should use that converter over what the default is.
EX:
In your stripes package you create:
public class StringEscapeTypeConverter extends StringTypeConverter implements
TypeConverter<String>
We do this because we want the default case to be secure and escape html and
javascript syntax for every string entered into the site.
However, in a few cases you don't want to do this, say for password creation.
So in that case we do a:
@Validate(field = "password", converter=StringTypeConverter.class)
In 1.4 this would pick up StringTypeConverter for password, in 1.5 this picks
up StringEscapeTypeConverter.
The issue is in DefaultActionBeanPropertyBinder.convert(....) :
converter = factory.getTypeConverter(declaredType, locale);
if (validationInfo != null && validationInfo.converter() != null) {
// If a specific converter was requested and it's the same type as
one we'd use
// for the delcared type, set the return type appropriately
if (converter != null &&
validationInfo.converter().isAssignableFrom(converter.getClass())) {
returnType = declaredType;
}
// Otherwise assume that it's a converter for the scalar type
inside a collection
else {
converter = factory.getInstance(validationInfo.converter(),
locale);
returnType = scalarType;
}
}
Which I think should be:
converter = factory.getTypeConverter(declaredType, locale);
if (validationInfo != null && validationInfo.converter() != null) {
// Always use validationInfo.converter if it exists
converter = factory.getInstance(validationInfo.converter(), locale);
// If a specific converter was requested and it's the same type as
one we'd use
// for the delcared type, set the return type appropriately
if (converter != null &&
validationInfo.converter().isAssignableFrom(converter.getClass())) {
returnType = declaredType;
}
// Otherwise assume that it's a converter for the scalar type
inside a collection
else {
returnType = scalarType;
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://www.stripesframework.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development