#~Local domain matching; returns /user@FQDN|user/ if address
#~ is local to Majordomo host ($whereami). Uses RegExp only if local.
#=============================================================================
# ADDRESS LOOKUP CUSTOMIZATIONS
#=============================================================================
# %siteaddr is an array which defines the prompts (with suitable local
# examples) associated with the opening form input.
#
# siteaddr() is an address-mapping function used to tie an address [or
# possibly name] to a set of address regexp's. These regexp's will be
# used to determine list membership.
#
# by_siteaddr() is a address-comparison function used for the sorting of
# subscriber addresses.
#-----------------------------------------------------------------------------
%siteaddr = (
'prompt',"Your E-Mail Address",
'browse',"Enter your e-mail address:
(e.g.: \"jdoe\@host.dom.ain\")",
);
#-----------------------------------------------------------------------------
# siteaddr()
#
# Function should return a 3-tuple list:
# user: given "real name" of user
# address: preferred address of user
# pattern: regexp of address patterns to match
#
# The "pattern" regexp enables MajorCool to identify list members even if
# they may be subscribed with multiple addresses.
#
sub siteaddr {
local($target) = @_;
# weed out bogus attempts
&send_error("<$target> is not a valid e-mail address.")
unless &valid_addr($target);
#
# valid_addr() only checks for filenames, pipes, -args, and
# other potential mail security problems. It does nothing to
# prevent syntactially incorrect addresses from being used. If
# you want to do a little more checking, consider using this
# regexp contributed by to check
# for user@host.dom.ain address formats. Or invent your own.
#
# $target =~
# /([\w-\.]+)@(([\w-\.]+\.)?[a-z]([\w-]{0,62}[\w])\.([a-z]){2,3})$/i;
# &send_error("$target is not a valid e-mail address.")
# unless $1 && $2;
#
local($lhs,@rhs) = split(/[!%@]/, $target);
&send_error("<$target> is not a valid e-mail address.")
unless $lhs ne "" && $#rhs >= 0;
return ($target, $target, "") if @rhs[0] !~ /^$whereami$/i;
# no regexp spoofs of user-id
&send_error("Bad user-id format.")
unless $lhs =~ /^([\-\w\d\._]+)$/;
local($regex) = "^$target\$";
$regex .= "|^$lhs\$";
$regex =~ s/\./\\./g; # periods are real, not meta
return ($target, $target, $regex);
}
#-----------------------------------------------------------------------------
# by_siteaddr()
#
# Function should return {-1,0,+1} depending on the comparison of the
# two array elements.
#
sub by_siteaddr {
$a cmp $b;
}
1; # keep require happy