Commit 18f33cc1 authored by Kevin Falcone's avatar Kevin Falcone
Browse files

Merge branch '3.0/longer-email-tlds' into 3.0-trunk

parents 6ac5f7b6 1ea8f6d0
......@@ -201,7 +201,7 @@ my @types = (
},
{
name => "email",
regex => qr{(?:mailto:)?<?[\w\.\+-]+\@[\w\.-]+\.\w{2,3}>?},
regex => qr{(?:mailto:)?<?[\w\.\+-]+\@[\w\.-]+\.\w{2,}>?},
action => "email",
},
{
......
......@@ -3,7 +3,7 @@
use strict;
use warnings;
use RT::IR::Test tests => 33;
use RT::IR::Test tests => undef;
RT::Test->started_ok;
my $agent = default_agent();
......@@ -47,3 +47,48 @@ diag "clicky ip" if $ENV{'TEST_VERBOSE'};
ok(!grep( lc($_->text||'') eq 'lookup ip', @links ), "not found link");
}
diag "clicky email" if $ENV{'TEST_VERBOSE'};
{
for my $email (
'foo@example.com', 'foo-bar+baz@example.me',
'foo@example.mobi', 'foo@localhost.localhost',
)
{
diag "test valid email $email" if $ENV{TEST_VERBOSE};
my ( $name, $domain ) = split /@/, $email, 2;
my $id =
$agent->create_ir( { Subject => 'clicky email', Content => $email } );
$agent->display_ticket($id);
my $email_link = $agent->find_link( text_regex => qr/\Qlookup email\E$/ );
my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
$agent->save_content('/tmp/x.html');
if ( $clicky{'email'} ) {
ok( $email_link, "found link" );
ok( $email_link->url =~ /(?<!\w)\Q$email\E(?!\w)/, 'url has an email' );
ok( $domain_link, "found link" );
ok( $domain_link->url =~ /(?<!\w)\Q$domain\E(?!\w)/, 'url has a domain' );
}
else {
ok( !$email_link, "not found email link" );
ok( !$domain_link, "not found domain link" );
}
}
for my $email ( 'foo@example', '@example.com', ) {
diag "test invalid email $email" if $ENV{TEST_VERBOSE};
my ( $name, $domain ) = split /@/, $email, 2;
my $id = $agent->create_ir( { Subject => 'clicky email', Content => $email } );
$agent->display_ticket($id);
my $email_link = $agent->find_link( text_regex => qr/\Qlookup email\E$/ );
ok( !$email_link, "not found email link" );
my $domain_link = $agent->find_link( text_regex => qr/^\Qlookup "$domain"\E$/i );
ok( !$domain_link, "not found domain link" );
}
}
done_testing;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment