You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Brian Bezanson <de...@bezanson.org> on 2004/11/22 15:21:08 UTC

Struts 1.2.4/Validator 1.1.3 and constant validation issue with '&' for constant-value

Hello. I'm trying to create a mask for use in password fields that accepts:
    - UPPERCASE A-Z
    - lowercase a-z
    - Numbers 0-9
    - Special Characters !,@,#,$,%,^,&,(,), and *

In the "validation.xml" file I have the following defined.

<form-validation>
  <global>
    <constant>
      <constant-name>password</constant-name>
      <constant-value>^[A-Za-z0-9!@#$%\^&*()]*$</constant-value>
    </constant>
  </global>
...
...
</form-validation>

When I start my application server (Tomcat 5.x) and the struts 
validation code starts to load my rules I get the following messages:

11-04-2004 11:46:19 struts.validator.ValidatorPlugIn - Loading 
validation rules file from '/WEB-INF/validator-rules.xml'
11-04-2004 11:46:19 struts.validator.ValidatorPlugIn - Loading 
validation rules file from '/WEB-INF/validator-rules-custom.xml'
11-04-2004 11:46:19 struts.validator.ValidatorPlugIn - Loading 
validation rules file from '/WEB-INF/validation.xml'
11-04-2004 11:46:20 commons.digester.Digester - Parse Fatal Error at 
line 22 column 39: The entity name must immediately follow the '&' in 
the entity reference.
org.xml.sax.SAXParseException: The entity name must immediately follow 
the '&' in the entity reference.

Removing the '&' from the constant-value allows the application to start 
properly, however I can't use the '&' as a valid input character.

Going to the url below to use the regexp sample applet, my original 
string with the '&' does work.

http://jakarta.apache.org/regexp/applet.html
Regular Expression: [A-Za-z0-9!@#$%\^&*()]*
String:             AZaz09!@#$%*()^&done

I am using commons-validator 1.1.3 with Struts 1.2.4

Any thoughts, fixes, or suggestions are much appreciated.

Brian


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts 1.2.4/Validator 1.1.3 and constant validation issue with '&' for constant-value

Posted by Simon Matic Langford <si...@pcmsgroup.com>.
it's an xml thing, try putting &amp; instead of & as & is a special
character
for xml which starts an entity, and &amp; is the entity for an ampersand
:-)
 

> -----Original Message-----
> From: Brian Bezanson [mailto:developer@bezanson.org] 
> Sent: 22 November 2004 14:21
> To: Struts Users Mailing List
> Subject: Struts 1.2.4/Validator 1.1.3 and constant validation 
> issue with '&' for constant-value
> 
> 
> Hello. I'm trying to create a mask for use in password fields 
> that accepts:
>     - UPPERCASE A-Z
>     - lowercase a-z
>     - Numbers 0-9
>     - Special Characters !,@,#,$,%,^,&,(,), and *
> 
> In the "validation.xml" file I have the following defined.
> 
> <form-validation>
>   <global>
>     <constant>
>       <constant-name>password</constant-name>
>       <constant-value>^[A-Za-z0-9!@#$%\^&*()]*$</constant-value>
>     </constant>
>   </global>
> ...
> ...
> </form-validation>
> 
> When I start my application server (Tomcat 5.x) and the struts 
> validation code starts to load my rules I get the following messages:
> 
> 11-04-2004 11:46:19 struts.validator.ValidatorPlugIn - Loading 
> validation rules file from '/WEB-INF/validator-rules.xml'
> 11-04-2004 11:46:19 struts.validator.ValidatorPlugIn - Loading 
> validation rules file from '/WEB-INF/validator-rules-custom.xml'
> 11-04-2004 11:46:19 struts.validator.ValidatorPlugIn - Loading 
> validation rules file from '/WEB-INF/validation.xml'
> 11-04-2004 11:46:20 commons.digester.Digester - Parse Fatal Error at 
> line 22 column 39: The entity name must immediately follow the '&' in 
> the entity reference.
> org.xml.sax.SAXParseException: The entity name must 
> immediately follow 
> the '&' in the entity reference.
> 
> Removing the '&' from the constant-value allows the 
> application to start 
> properly, however I can't use the '&' as a valid input character.
> 
> Going to the url below to use the regexp sample applet, my original 
> string with the '&' does work.
> 
http://jakarta.apache.org/regexp/applet.html
Regular Expression: [A-Za-z0-9!@#$%\^&*()]*
String:             AZaz09!@#$%*()^&done

I am using commons-validator 1.1.3 with Struts 1.2.4

Any thoughts, fixes, or suggestions are much appreciated.

Brian


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org