[Rt-commit] [rtir] 01/01: allow all the 2+ letter tlds for email and test for this
? sunnavy
sunnavy at bestpractical.com
Thu Apr 10 10:55:50 EDT 2014
This is an automated email from the git hooks/post-receive script.
sunnavy pushed a commit to branch 3.0/longer-email-tlds
in repository rtir.
commit 1ea8f6d08dc52e814586a3440aec81b4b7fc9fb9
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jan 4 12:00:19 2011 +0800
allow all the 2+ letter tlds for email and test for this
Conflicts:
t/015-make-clicky.t
---
html/Callbacks/RTIR/Elements/MakeClicky/Default | 2 +-
t/015-make-clicky.t | 47 ++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/html/Callbacks/RTIR/Elements/MakeClicky/Default b/html/Callbacks/RTIR/Elements/MakeClicky/Default
index d59481e..876c188 100644
--- a/html/Callbacks/RTIR/Elements/MakeClicky/Default
+++ b/html/Callbacks/RTIR/Elements/MakeClicky/Default
@@ -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",
},
{
diff --git a/t/015-make-clicky.t b/t/015-make-clicky.t
index 42344fd..e930c81 100644
--- a/t/015-make-clicky.t
+++ b/t/015-make-clicky.t
@@ -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 at example.com', 'foo-bar+baz at example.me',
+ 'foo at example.mobi', 'foo at 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 at 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;
+
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the rt-commit
mailing list