EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #00417


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: Email MetaField validation


On Wed, 2012-04-18 at 16:10 +1000, Matthew Kerwin wrote:
> In our ePrints installation we decided to make things a little easier
>  on the human when importing eprints, by relaxing validation to allow
>  leading and trailing whitespace.  To accommodate this relaxation I
>  modified EPrints::MetaField::Email, adding a form_value_basic method
>  that subsequently strips said whitespace, thus:
> 
> ----------
> sub form_value_basic
> {
> 	my $self = shift;
> 	my $v = $self->SUPER::form_value_basic( @_ );
> 	# strip leading and trailing whitespace
> 	$v =~ s/^\s+|\s+$//g;
> 	return $v;
> }
> ----------
>
> Is this the right approach, or is there a better point where I can
>  intercept the data before it hits our back-end store?  And if this is
>  the right place for sanitisation, should the method be patched in
>  upstream?

If you wanted to override a single field you could set its "fromform"
property.

Either way, the "form_value_basic" method is unlikely to change anytime
soon, so you should be safe overriding that method.

> Further, is there a reason that any meta-field would ever want leading
>  and trailing whitespace?  Whatever approach ends up being used to
>  sanitise the data, should it apply to all meta-fields, or just email?

I have pondered this before. I think I was just scared about making such
a wide-ranging change :-)

-- 
All the best,
Tim

Attachment: signature.asc
Description: This is a digitally signed message part