Adam
On 04/01/2004 11:59 PM Niall Pemberton wrote:
Adam Hardy <[EMAIL PROTECTED]> wrote
I was merely adopting the three optional configuration settings that are used in UrlValidator already. I think your suggestion of a comma-delimited list of schemas sounds easiest, plus it has precedents in other config parameter settings, e.g. list of roles in an action mapping.
The other suggestion ("var" starting with "scheme") is also straight forward - there is a getVars() method in Field which returns a Map of all the vars, so it would be easy to iterate over them picking out those that start with "scheme".
I'm easy going on which solution to choose - the important thing is to get something concrete that implements you configuration suggestion.
Re an 'all' option, wouldn't it be easier if no schemas are mentioned or the parameter is absent, then all are allowed?
FieldChecks currently uses the UrlValidator defaults ("http", "https" and "ftp") which I think should be the allowed schemes if none are mentioned.
Also on the instantiation front, you mean that in FieldChecks, if there are any parameters for validateUrl set, then instantiate a new UrlValidator, otherwise use the GenericValidator.isUrl()?
Yes.
I was thinking of openning a bugzilla and sticking a patch up - but I don't want to steal your thunder if you'd rather do it.
Niall
Adam
On 04/01/2004 10:08 PM Niall Pemberton wrote:
Adam Hardy suggested "allow2slashes", "nofragments" and
"allowallschemes"
being either true/false
I think rather than having "allowallschemes", have a "schemes" parameter which can be either "all" (which sets the allow all schemes option) or a comma delimited list of valid schemes.
Alternatively you could have Adam's suggestion plus any <var> that
starts
with "scheme" is taken to build an array of schemes. Something like:
<field property="someUrl" depends="myUrlValidator"> <var><var-name>allow2slashes</var-name> <var-value>true</var-value> </var> <var><var-name>nofragments</var-name> <var-value>true</var-value> </var> <var><var-name>allowallschemes</var-name> <var-value>false</var-value> </var> <var><var-name>scheme1</var-name> <var-value>http</var-value> </var> <var><var-name>scheme2</var-name> <var-value>ftp</var-value> </var> <var><var-name>scheme3</var-name> <var-value>telnet</var-value> </var> </field>
Niall
----- Original Message ----- From: "David Graham" <[EMAIL PROTECTED]>
To: "Struts Developers List" <[EMAIL PROTECTED]>
Sent: Thursday, April 01, 2004 8:17 PM
Subject: Re: Fw: UrlValidator() takes options - but how?
--- Niall Pemberton <[EMAIL PROTECTED]> wrote:
Sorry this went to the wrong list, but anyway....
Looking at CVS there is a validateUrl() method in the Struts
FieldChecks
class (added in version 1.15) - problem is it uses commons GenericValidator which has a static instance.
What do you think about changing this to instantiate a UrlValidator if any configuration parameters have been enetered in validation.xml,
otherwise
use the GenericValidator?
Sounds ok to me but we need to define the variable names the method recognizes and will use in UrlValidator configuration.
David
-- struts 1.2 + tomcat 5.0.19 + java 1.4.2 Linux 2.4.20 Debian
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- struts 1.2 + tomcat 5.0.19 + java 1.4.2 Linux 2.4.20 Debian
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]