struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Qunhuan Mei (JIRA)" <>
Subject [jira] Commented: (WW-3119) Stringlength validation problem for utf-8 chars (Struts 2.1.6)
Date Thu, 17 Jun 2010 20:14:26 GMT


Qunhuan Mei commented on WW-3119:

yes, fortunately! :-)

Hi Xiao Dai (may be last time to call you Xiao ... :-)  ) and CongLin,

Thanks for your contacts. I am still in London, live a very quiet life with
my wife and daughter.

Do think of you very often. Shame no marvelous things to share with you.






> Stringlength validation problem for utf-8 chars (Struts 2.1.6)
> --------------------------------------------------------------
>                 Key: WW-3119
>                 URL:
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.1.6
>         Environment: Win XP, Eclipes, Tomcat
>            Reporter: Qunhuan Mei
>            Assignee: Wes Wannemacher
>            Priority: Critical
>             Fix For: 2.1.8
> When I try to validate utf-8 chars such as Chinese using Struts 2.1.6, the stringlength
validation appears to have problem. It seems the validation process is not using the number
of Chinese chars before encoding, but rather the number of chars after encoding. The following
are the steps to reproduce the problem:
> 1.	Create a project by importing struts2-blank-2.1.6.war from ...\struts-2.1.6\apps"

> and make the login.jsp work with, e.g. print out the username.length() in
setUsername(...) function.
> 2.	copy the following stringlength validation code into Login-validation.xml:
> <field-validator type="stringlength">
>         	<param name="maxLength">4</param>
>         	<param name="trim">true</param>
>         	<message key="fieldNameShouldBeWithinMaxLength"/>        	
> </field-validator>
> 3.	copy the following stringlength error message into
> fieldNameShouldBeWithinMaxLength=The max number of chars of ${getText(fieldName)} is
> 4.	run the login.jsp and type in either "abcd" and "abcde" into username, we can see
that "abcd" does not incur a validation message whereas "abcde" does.
> 5.	now typing 2 Chinese chars, say "世界"into the user name, which should not have
any problem since only 2 chars. However the struts reports the chars received are more than
4. As a matter of fact, the print out statement in setUsername(...) reports the number of
chars is 6.
> Qunhuan Mei
> BTW: is there any way to access the validation code from struts 2.1.7 (this bug may have
been fixed by the 2.1.7 code)? Thanks.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message