Skip to content

Commit 2d3e321

Browse files
committed
allow email_get_containing to use similar to instead of like
Lets you do a bit more subtle matching
1 parent 38582fc commit 2d3e321

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

perllib/mySociety/WebTestHarness.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,8 @@ mails are found within a few seconds, or there is more than one match. The
669669
email is returned with any quoted printable characters decoded.
670670
671671
=cut
672-
sub email_get_containing($$) {
673-
my ($self, $check) = @_;
672+
sub email_get_containing($$;$) {
673+
my ($self, $check, $regex) = @_;
674674

675675
die "STRING must be scalar or array" if (ref($check) ne 'ARRAY' && ref($check) ne '');
676676
$check = [ $check ] if (ref($check) eq '');
@@ -688,7 +688,8 @@ sub email_get_containing($$) {
688688
my $quoted_c = encode_qp($c, "");
689689
push @params, $quoted_c;
690690
}
691-
$qfragment = join($bool, map { 'content like ?' } @params);
691+
my $match_op = defined $regex ? 'content similar to ?' : 'content like ?';
692+
$qfragment = join($bool, map { $match_op } @params);
692693
$qdesc = join($bool, map { "'$_'" } @params);
693694

694695
# Provoke any sending of mails

0 commit comments

Comments
 (0)