This file is indexed.

/usr/share/perl5/Data/Validate/Email.pm is in libdata-validate-email-perl 0.04-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
package Data::Validate::Email;

use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

require Exporter;
use AutoLoader 'AUTOLOAD';

use Email::Address;
use Data::Validate::Domain;

@ISA = qw(Exporter);



# no functions are exported by default.  See EXPORT_OK
@EXPORT = qw();

@EXPORT_OK = qw(
		is_email
		is_email_rfc822
		is_domain
		is_username
);

%EXPORT_TAGS = ();

$VERSION = '0.04';


# No preloads

1;
__END__

=head1 NAME

Data::Validate::Email - common email validation methods

=head1 SYNOPSIS

  use Data::Validate::Email qw(is_email is_email_rfc822);

  if(is_email($suspect)){
  	print "Looks like an email address\n";
  } elsif(is_email_rfc822($suspect)){
  	print "Doesn't much look like an email address, but passes rfc822\n";
  } else {
  	print "Not an email address\n";
  }

  # or as an object
  my $v = Data::Validate::Email->new();

  die "not an email" unless ($v->is_email('foo'));

=head1 DESCRIPTION

This module collects common email validation routines to make input validation,
and untainting easier and more readable. 

All functions return an untainted value if the test passes, and undef if
it fails.  This means that you should always check for a defined status explicitly.
Don't assume the return will be true. (e.g. is_username('0'))

The value to test is always the first (and often only) argument.

=head1 FUNCTIONS

=cut

# -------------------------------------------------------------------------------

=pod

=over 4

=item B<new> - constructor for OO usage

  new([\%opts]);

=over 4

=item I<Description>

Returns a Data::Validator::Email object.  This lets you access all the validator function
calls as methods without importing them into your namespace or using the clumsy
Data::Validate::Email::function_name() format.

=item I<Arguments>

An optional hash reference is retained and passed on to other function calls in the
Data::Validate module series.  This module does not utilize the extra data,
but some child calls do.  See Data::Validate::Domain for an example.

=item I<Returns>

Returns a Data::Validate::Email object

=back

=cut

sub new{
	my $class = shift;
	my %self = @_;
	
	return bless \%self, ref($class) || $class;
}

# -------------------------------------------------------------------------------

=pod

=item B<is_email> - is the value a well-formed email address?

  is_email($value);

=over 4

=item I<Description>

Returns the untainted address if the test value appears to be a well-formed
email address.  This method tries to match real-world addresses, rather than
trying to support everything that rfc822 allows.  (see is_email_rfc822 if you want the
more permissive behavior.)

In short, it pretty much looks for something@something.tld.  It does not understand
real names ("bob smith" <bsmith@test.com>), or other comments.  It will not accept
partially-qualified addresses ('bob', or 'bob@machine')

=item I<Arguments>

=over 4

=item $value

The potential address to test.

=back

=item I<Returns>

Returns the untainted address on success, undef on failure.

=item I<Notes, Exceptions, & Bugs>

This function does not make any attempt to check whether an address is 
genuinely deliverable. It only looks to see that the format is email-like.

The function accepts an optional hash reference as a second argument to 
change the validation behavior.  It is passed on unchanged to Neil Neely's
Data::Validate::Domain::is_domain() function.  See that module's documentation
for legal values.

=back

=cut

sub is_email{
	my $self = shift if ref($_[0]); 
	my $value = shift;
	
	return unless defined($value);
	
	my $opt = (defined $self) ? $self : (shift);
	
	my @parts = split(/\@/, $value);
	return unless scalar(@parts) == 2;
	
	my($user) = is_username($parts[0], $opt);
	return unless defined($user);
	return unless $user eq $parts[0];
	
	my $domain = is_domain($parts[1], $opt);
	return unless defined($domain);
	return unless $domain eq $parts[1];

	return $user . '@' . $domain;
}


# -------------------------------------------------------------------------------

=pod

=item B<is_email_rfc822> - does the value look like an RFC 822 address?

  is_email_rfc822($value);

=over 4

=item I<Description>

Returns the untainted address if the test value appears to be a well-formed
email address according to RFC822. Note that the standard allows for a wide
variety of address formats, including ones with real names and comments.

In most cases you probably want to use is_email() instead.  This one will
accept things that you probably aren't expecting ('foo@bar', for example.)  

=item I<Arguments>

=over 4

=item $value

The potential address to test.

=back

=item I<Returns>

Returns the untainted address on success, undef on failure.

=item I<Notes, Exceptions, & Bugs>

This check uses Casey West's Email::Address module to do its validation.

The function does not make any attempt to check whether an address is 
genuinely deliverable. It only looks to see that the format is email-like.

=back

=cut

sub is_email_rfc822{
	my $self = shift if ref($_[0]); 
	my $value = shift;
	
	return unless defined($value);
	
	#warn $Email::Address::mailbox;
	
	my $address;
	if($value =~ /^$Email::Address::mailbox$/){
		#warn $&;
		$address = $&;
	}
	
	return $address;
}


# -------------------------------------------------------------------------------

=pod

=item B<is_domain> - does the value look like a domain name?

  is_domain($value);

=over 4

=item I<Description>

Returns the untainted domain if the test value appears to be a well-formed
domain name.  This test uses the same logic as is_email(), rather than the
somewhat more permissive pattern specified by RFC822. 

=item I<Arguments>

=over 4

=item $value

The potential domain to test.

=back

=item I<Returns>

Returns the untainted domain on success, undef on failure.

=item I<Notes, Exceptions, & Bugs>

The function does not make any attempt to check whether a domain is 
actually exists. It only looks to see that the format is appropriate.

As of version 0.03, this is a direct pass-through to Neil Neely's
Data::Validate::Domain::is_domain() function.

The function accepts an optional hash reference as a second argument to 
change the validation behavior.  It is passed on unchanged to Neil Neely's
Data::Validate::Domain::is_domain() function.  See that module's documentation
for legal values.

=back

=cut

sub is_domain{
	my $self = shift if ref($_[0]); 
	my $value = shift;
	
	return unless defined($value);
	
	my $opt = (defined $self) ? $self : (shift);
	
	return Data::Validate::Domain::is_domain($value, $opt);
}


# -------------------------------------------------------------------------------

=pod

=item B<is_username> - does the value look like a username?

  is_username($value);

=over 4

=item I<Description>

Returns the untainted username if the test value appears to be a well-formed
username.  More specifically, it tests to see if the value is legal as the
username component of an email address as defined by is_email().  Note that
this definition is more restrictive than the one in RFC822.

=item I<Arguments>

=over 4

=item $value

The potential username to test.

=back

=item I<Returns>

Returns the untainted username on success, undef on failure.

=item I<Notes, Exceptions, & Bugs>

The function does not make any attempt to check whether a username
actually exists on your system. It only looks to see that the format is
appropriate.

=back

=cut

sub is_username{
	my $self = shift if ref($_[0]); 
	my $value = shift;
	
	return unless defined($value);
	
	my($username) = $value =~ /^([a-z0-9_\-\.]+)$/i;
	
	return $username;
}


=pod

=back

=head1 AUTHOR

Richard Sonnen <F<sonnen@richardsonnen.com>>.

=head1 COPYRIGHT

Copyright (c) 2004 Richard Sonnen. All rights reserved.

This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut