[Rt-commit] [rtir] 01/01: allow all the 2+ letter tlds for email and test for this

Kevin Falcone falcone at bestpractical.com
Wed Apr 9 14:58:56 EDT 2014


This is an automated email from the git hooks/post-receive script.

falcone pushed a commit to branch 3.0/longer-email-tlds
in repository rtir.

commit 8503330b84b38b6ce54506c183619628a4212643
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                             | 54 ++++++++++++++++++++++++-
 2 files changed, 54 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..2129945 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,55 @@ 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 @links = $agent->followable_links;
+        if ( $clicky{'email'} ) {
+            my ($email_link) = grep lc $_->text eq 'lookup email', @links;
+            ok( $email_link, "found link" );
+            ok( $email_link->url =~ /(?<!\w)\Q$email\E(?!\w)/,
+                'url has an email' );
+
+            my ($domain_link) = grep lc $_->text eq qq{lookup "$domain"},
+              @links;
+            ok( $domain_link, "found link" );
+            ok( $domain_link->url =~ /(?<!\w)\Q$domain\E(?!\w)/,
+                'url has a domain' );
+        }
+        else {
+            ok( !grep( lc $_->text eq 'lookup email', @links ),
+                "not found email link" );
+            ok( !grep( lc $_->text eq qq{lookup "$domain"}, @links ),
+                "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 @links = $agent->followable_links;
+        ok( !grep( lc $_->text eq 'lookup email', @links ),
+            "not found email link" );
+        ok( !grep( lc $_->text eq qq{lookup "$domain"}, @links ),
+            "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