[Rt-commit] rt branch, 4.4/subject-tag-http-prefix, created. rt-4.4.4-52-g4aad9e6d5
? sunnavy
sunnavy at bestpractical.com
Tue Jul 30 09:02:00 EDT 2019
The branch, 4.4/subject-tag-http-prefix has been created
at 4aad9e6d58b79fabfc1aad2fb8e682bd74f4fc48 (commit)
- Log -----------------------------------------------------------------
commit e92d7ef03939077fd21f886b54ecdb8184f56ff3
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jul 30 20:42:07 2019 +0800
In case subject tag is prefixed with http:// by email clients
We noticed that recent Outlook 365 for web automatically converts things
that look like a domain from example.com to http://example.com in
subject, which breaks our parsing ticket id logic.
This commit tolerates related regexes to allow http:// prefix.
diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 970e424cd..e88248e5b 100644
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -631,11 +631,11 @@ sub ParseTicketId {
# We use @captures and pull out the last capture value to guard against
# someone using (...) instead of (?:...) in $EmailSubjectTagRegex.
my $id;
- if ( my @captures = $Subject =~ /\[$test_name\s+\#(\d+)\s*\]/i ) {
+ if ( my @captures = $Subject =~ m{\[(?:http://)?$test_name\s+\#(\d+)\s*\]}i ) {
$id = $captures[-1];
} else {
foreach my $tag ( RT->System->SubjectTag ) {
- next unless my @captures = $Subject =~ /\[\Q$tag\E\s+\#(\d+)\s*\]/i;
+ next unless my @captures = $Subject =~ m{\[(?:http://)?\Q$tag\E\s+\#(\d+)\s*\]}i;
$id = $captures[-1];
last;
}
commit 4aad9e6d58b79fabfc1aad2fb8e682bd74f4fc48
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jul 30 20:48:01 2019 +0800
Test subject tag with unexpected http:// prefix
diff --git a/t/api/rtname.t b/t/api/rtname.t
index f2bffd559..fe1d26064 100644
--- a/t/api/rtname.t
+++ b/t/api/rtname.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use RT::Test nodata => 1, tests => 12;
+use RT::Test nodata => 1, tests => undef;
use RT::Interface::Email;
@@ -36,3 +36,15 @@ RT->Config->Set( EmailSubjectTagRegex => qr/(new|)(site)/ );
is(RT::Interface::Email::ParseTicketId("[site #123] test"), 123);
is(RT::Interface::Email::ParseTicketId("[newsite #123] test"), 123);
is(RT::Interface::Email::ParseTicketId("[othersite #123] test"), undef);
+
+# extra http:// added by Outlook 365 for web
+RT->Config->Set( rtname => 'site.com' );
+RT->Config->Set( EmailSubjectTagRegex => undef );
+is(RT::Interface::Email::ParseTicketId("[http://site.com #123] test"), 123);
+is(RT::Interface::Email::ParseTicketId("[http://othersite.com #123] test"), undef);
+
+RT->Config->Set( EmailSubjectTagRegex => qr/\Qsite.com\E/ );
+is(RT::Interface::Email::ParseTicketId("[http://site.com #123] test"), 123);
+is(RT::Interface::Email::ParseTicketId("[http://othersite.com #123] test"), undef);
+
+done_testing;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list