[Rt-commit] rtir branch, 5.0/extract-domain, repushed
? sunnavy
sunnavy at bestpractical.com
Fri Jun 12 16:43:38 EDT 2020
The branch 5.0/extract-domain was deleted and repushed:
was 289a742cc767409b2268a0cfded63c765e85f367
now 9dece5ec262e69af0dfdb553d2efac441760aae0
1: 767bc3cc ! 1: fc3d4623 Extract domains to custom field Domain
@@ -14,7 +14,7 @@
+ Net::Domain::TLD: 0
Parse::BooleanLogic: 0
Regexp::Common: 0
- perl: 5.10.1
+ Net::Whois::RIPE: 2.006001
diff --git a/Makefile.PL b/Makefile.PL
--- a/Makefile.PL
@@ -42,6 +42,23 @@
'Details' => ['How Reported','Reporter Type','Customer',
'Description', 'Resolution', 'Function', 'Classification',
'Customer',
+@@
+ ],
+ );
+
++=item C<$RTIR_StrictDomainTLD>
++
++If true then RTIR will check if TLD is officially valid on domain
++extraction. Set it to 0 if you need to support local TLDs or recent ones
++that are not included in L<Net::Domain::TLD> yet. It's true by default.
++
++=cut
++
++Set($RTIR_StrictDomainTLD, 1);
++
+ =back
+
+ =head1 Countermeasures
diff --git a/etc/initialdata b/etc/initialdata
--- a/etc/initialdata
@@ -236,9 +253,7 @@
+package RT::Action::RTIR_FindDomain;
+use base qw(RT::Action::RTIR);
+
-+use Net::Domain::TLD 'tld_exists';
-+
-+# https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9781449327453/ch08s15.html
++# See Regular Expressions Cookbook, 2nd Edition: 8.15. Validating Domain Names
+my $regex = qr/\b((?:(?=[a-z0-9-]{1,63}\.)(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\.)+([a-z]{2,63}))\b/;
+
+=head2 Commit
@@ -273,7 +288,11 @@
+ my $domain = $1;
+ my $tld = $2;
+
-+ next unless length $domain <= 253 && tld_exists( $tld );
++ next unless length $domain <= 253;
++ if ( RT->Config->Get('RTIR_StrictDomainTLD') ) {
++ require Net::Domain::TLD;
++ next unless Net::Domain::TLD::tld_exists($tld);
++ }
+
+ $self->AddDomain(
+ Domain => $domain,
2: 289a742c ! 2: 9dece5ec Test domain extraction
@@ -286,4 +286,25 @@
+ }
+}
+
++RT::Test->stop_server;
++RT->Config->Set( 'RTIR_StrictDomainTLD', 0 );
++RT::Test->started_ok;
++
++$agent = default_agent();
++
++diag "test invalid tld domains without strict domain tld";
++{
++ my @invalid_domains = (
++ 'test.bla',
++ );
++
++ for my $domain ( @invalid_domains ) {
++ my $id = $agent->create_rtir_ticket_ok( 'Incident Reports', { Subject => "test", Content => $domain }, );
++ my $ticket = RT::Ticket->new( $RT::SystemUser );
++ $ticket->Load( $id );
++ ok( $ticket->id, 'loaded ticket' );
++ is( $ticket->FirstCustomFieldValue( 'Domain' ), $domain, "Domain $domain is extracted" );
++ }
++}
++
+done_testing;
More information about the rt-commit
mailing list