[EP-tech] Email MetaField validation
Matthew Kerwin
matthew.kerwin at qut.edu.au
Wed Apr 18 07:10:50 BST 2012
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?
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?
Cheers
--
Matthew Kerwin | Web Developer | TILS | Digital Repository Team | Level 2, I Block, Kelvin Grove | ph 3138 3910 | matthew.kerwin at qut.edu.au | CRICOS No 00213J
More information about the Eprints-tech
mailing list