git: cbc3df9aae00 - main - dns/p5-Domain-PublicSuffix: New port

From: Norikatsu Shigemura <nork_at_FreeBSD.org>
Date: Mon, 19 Oct 2026 09:03:49 UTC
The branch main has been updated by nork:

URL: https://cgit.FreeBSD.org/ports/commit/?id=cbc3df9aae00c73194885be0bb2c3b335e7479a3

commit cbc3df9aae00c73194885be0bb2c3b335e7479a3
Author:     Norikatsu Shigemura <nork@FreeBSD.org>
AuthorDate: 2026-10-19 09:00:44 +0000
Commit:     Norikatsu Shigemura <nork@FreeBSD.org>
CommitDate: 2026-10-19 09:00:44 +0000

    dns/p5-Domain-PublicSuffix: New port
    
    A perl module to parse a domain down to the root TLD utilizing the
    Mozilla Public Suffix List.
    This module utilizes the "public_suffix_list.dat" or "effective_tld_names.dat"
    provided by Mozilla as a way to effectively reduce a fully qualified
    domain name down to the absolute root. The Mozilla PublicSuffix file
    is an open source, fully documented format that shows absolute root
    TLDs, primarily for Mozilla's browser products to be able to determine
    how far a cookie's security boundaries go.
    
    Approved by:    hrs (mentor)
---
 dns/Makefile                                       |  1 +
 dns/p5-Domain-PublicSuffix/Makefile                | 30 ++++++++
 dns/p5-Domain-PublicSuffix/distinfo                |  3 +
 .../files/patch-lib_Domain_PublicSuffix.pm         | 85 ++++++++++++++++++++++
 dns/p5-Domain-PublicSuffix/files/patch-t_01-core.t | 11 +++
 .../files/patch-t_04-legacy.t                      | 11 +++
 .../files/patch-t_77-freebsd-ports-test.t          | 36 +++++++++
 dns/p5-Domain-PublicSuffix/pkg-descr               |  9 +++
 dns/p5-Domain-PublicSuffix/pkg-plist               |  6 ++
 9 files changed, 192 insertions(+)

diff --git a/dns/Makefile b/dns/Makefile
index dbf004887282..9456c2ec9534 100644
--- a/dns/Makefile
+++ b/dns/Makefile
@@ -125,6 +125,7 @@
     SUBDIR += p5-DNS-ZoneParse
     SUBDIR += p5-DNS-nsdiff
     SUBDIR += p5-Data-Validate-Domain
+    SUBDIR += p5-Domain-PublicSuffix
     SUBDIR += p5-IO-Async-Resolver-DNS
     SUBDIR += p5-Mozilla-PublicSuffix
     SUBDIR += p5-Net-Amazon-Route53
diff --git a/dns/p5-Domain-PublicSuffix/Makefile b/dns/p5-Domain-PublicSuffix/Makefile
new file mode 100644
index 000000000000..ea3214966e3b
--- /dev/null
+++ b/dns/p5-Domain-PublicSuffix/Makefile
@@ -0,0 +1,30 @@
+PORTNAME=	Domain-PublicSuffix
+PORTVERSION=	0.21
+CATEGORIES=	dns perl5
+MASTER_SITES=	CPAN
+MASTER_SITE_SUBDIR=	CPAN:NMELNICK
+PKGNAMEPREFIX=	p5-
+
+MAINTAINER=	nork@FreeBSD.org
+COMMENT=	Parse a domain down to the root TLD
+WWW=		https://metacpan.org/release/Domain-PublicSuffix
+
+LICENSE=	ARTPERL10 GPLv1+
+LICENSE_COMB=	dual
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+RUN_DEPENDS=	p5-Class-Accessor-Fast-XS>=0:devel/p5-Class-Accessor-Fast-XS \
+		p5-Net-IDN-Encode>=2.401:textproc/p5-Net-IDN-Encode \
+		public_suffix_list>0:dns/public_suffix_list
+
+USES=		perl5
+USE_PERL5=	configure
+
+NO_ARCH=	yes
+
+post-patch:
+		@${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \
+			${WRKSRC}/lib/Domain/PublicSuffix.pm
+		@${RM} ${WRKSRC}/lib/Domain/*.orig ${WRKSRC}/lib/Domain/*.bak
+
+.include <bsd.port.mk>
diff --git a/dns/p5-Domain-PublicSuffix/distinfo b/dns/p5-Domain-PublicSuffix/distinfo
new file mode 100644
index 000000000000..9f4c5b59b5ea
--- /dev/null
+++ b/dns/p5-Domain-PublicSuffix/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1791251566
+SHA256 (Domain-PublicSuffix-0.21.tar.gz) = d0903e7c6385b932dd0f537b584b8884111b9356e5fe44f3a9fc6310ce5c300d
+SIZE (Domain-PublicSuffix-0.21.tar.gz) = 125192
diff --git a/dns/p5-Domain-PublicSuffix/files/patch-lib_Domain_PublicSuffix.pm b/dns/p5-Domain-PublicSuffix/files/patch-lib_Domain_PublicSuffix.pm
new file mode 100644
index 000000000000..49e5075b49ab
--- /dev/null
+++ b/dns/p5-Domain-PublicSuffix/files/patch-lib_Domain_PublicSuffix.pm
@@ -0,0 +1,85 @@
+--- lib/Domain/PublicSuffix.pm.orig	2024-11-26 01:04:07 UTC
++++ lib/Domain/PublicSuffix.pm
+@@ -45,17 +45,19 @@ Domain::PublicSuffix - Parse a domain down to root
+ 
+ =head1 DESCRIPTION
+ 
+-This module utilizes the "effective_tld_names.dat" provided by Mozilla as a way
+-to effectively reduce a fully qualified domain name down to the absolute root.
+-The Mozilla PublicSuffix file is an open source, fully documented format that
+-shows absolute root TLDs, primarily for Mozilla's browser products to be able
+-to determine how far a cookie's security boundaries go.
++This module utilizes the "public_suffix_list.dat" or "effective_tld_names.dat"
++provided by Mozilla as a way to effectively reduce a fully qualified domain
++name down to the absolute root.  The Mozilla PublicSuffix file is an open source,
++fully documented format that shows absolute root TLDs, primarily for Mozilla's
++browser products to be able to determine how far a cookie's security boundaries
++go.
+ 
+-This module will attempt to search etc directories in /usr/share/publicsuffix,
+-/usr, /usr/local, and /opt/local for the effective_tld_names.dat file. If a file
+-is not found, a default file is loaded from Domain::PublicSuffix::Default, which
+-is current at the time of the module's release. You can override the data file
+-path by giving the new() method a 'data_file' argument.
++This module will attempt to search %%LOCALBASE%%/share/public_suffix_list,
++/usr/share/publicsuffix, /usr, /usr/local, and /opt/local for the
++public_suffix_list.dat or effective_tld_names.dat file. If a file is not found,
++a default file is loaded from Domain::PublicSuffix::Default, which is current at
++the time of the module's release. You can override the data file path by giving
++the new() method a 'data_file' argument.
+ 
+ When creating a new PublicSuffix object, the module will load the data file as
+ specified, and use the internal structure to parse each domain sent to the
+@@ -101,7 +103,8 @@ Can take a hashref of arguments:
+ 
+ =item data_file 
+ 
+-A fully qualified path, to override the effective_tld_names.dat file.
++A fully qualified path, to override the public_suffix_list.dat or
++effective_tld_names.dat file.
+ 
+ =item use_default 
+ 
+@@ -255,7 +258,7 @@ sub _load_data {
+ 
+ 	my $data_stream_ref;
+ 
+-	# Find an effective_tld_names.dat file
++	# Find an public_suffix_list.dat or effective_tld_names.dat file
+ 	my @tld_lines;
+ 	my $dat;
+ 	if ( $self->use_default ) {
+@@ -269,21 +272,25 @@ sub _load_data {
+ 
+ 	} else {
+ 		my @paths = (
++			File::Spec->catdir("%%LOCALBASE%%", qw/ share public_suffix_list /),
+ 			File::Spec->catdir(File::Spec->rootdir, qw/ usr share publicsuffix /),
+ 			File::Spec->catdir(File::Spec->rootdir, qw/ etc /),
+ 			File::Spec->catdir(File::Spec->rootdir, qw/ usr etc /),
+ 			File::Spec->catdir(File::Spec->rootdir, qw/ usr local etc /),
+ 			File::Spec->catdir(File::Spec->rootdir, qw/ opt local etc /),
+ 		);
++		FIND_DATA:
+ 		foreach my $path (@paths) {
+-			$path = File::Spec->catfile( $path, "effective_tld_names.dat" );
+-			if ( -e $path ) {
+-				open( $dat, '<:encoding(UTF-8)', $path )
+-					or die "Cannot open \'" . $path . "\': " . $!;
+-				@tld_lines = <$dat>;
+-				close($dat);
+-				$data_stream_ref = \@tld_lines;
+-				last;
++			foreach my $file (qw/ public_suffix_list.dat effective_tld_names.dat /) {
++				my $filepath = File::Spec->catfile( $path, $file );
++				if ( -e $filepath ) {
++					open( $dat, '<:encoding(UTF-8)', $filepath )
++						or die "Cannot open \'" . $filepath . "\': " . $!;
++					@tld_lines = <$dat>;
++					close($dat);
++					$data_stream_ref = \@tld_lines;
++					last FIND_DATA;
++				}
+ 			}
+ 		}
+ 	}
diff --git a/dns/p5-Domain-PublicSuffix/files/patch-t_01-core.t b/dns/p5-Domain-PublicSuffix/files/patch-t_01-core.t
new file mode 100644
index 000000000000..01f64c0a76c3
--- /dev/null
+++ b/dns/p5-Domain-PublicSuffix/files/patch-t_01-core.t
@@ -0,0 +1,11 @@
+--- t/01-core.t.orig	2024-11-26 01:04:07 UTC
++++ t/01-core.t
+@@ -30,7 +30,7 @@ $ps = Domain::PublicSuffix->new({ 
+ is( $ps->tld(), 'com',                                      , 'domain-error' );
+ 
+ $ps = Domain::PublicSuffix->new({ 
+-    'data_file' => 'effective_tld_names.dat'
++    'data_file' => 't/effective_tld_names.dat'
+ });
+ 
+ is( ref($ps), 'Domain::PublicSuffix',                       , 'create-external-object' );
diff --git a/dns/p5-Domain-PublicSuffix/files/patch-t_04-legacy.t b/dns/p5-Domain-PublicSuffix/files/patch-t_04-legacy.t
new file mode 100644
index 000000000000..68615c90f407
--- /dev/null
+++ b/dns/p5-Domain-PublicSuffix/files/patch-t_04-legacy.t
@@ -0,0 +1,11 @@
+--- t/04-legacy.t.orig	2024-11-26 01:04:07 UTC
++++ t/04-legacy.t
+@@ -5,7 +5,7 @@ my $ps = Domain::PublicSuffix->new({
+ use Domain::PublicSuffix;
+ 
+ my $ps = Domain::PublicSuffix->new({
+-    'dataFile' => 'effective_tld_names.dat'
++    'dataFile' => 't/effective_tld_names.dat'
+ });
+ is( $ps->getRootDomain('google.com'), 'google.com', 'compatibility' );
+ is( $ps->tld(), 'com',                            , 'compatibility-tld' );
diff --git a/dns/p5-Domain-PublicSuffix/files/patch-t_77-freebsd-ports-test.t b/dns/p5-Domain-PublicSuffix/files/patch-t_77-freebsd-ports-test.t
new file mode 100644
index 000000000000..5d2a23558115
--- /dev/null
+++ b/dns/p5-Domain-PublicSuffix/files/patch-t_77-freebsd-ports-test.t
@@ -0,0 +1,36 @@
+--- t/77-freebsd-ports-test.t.orig	1970-01-01 00:00:00 UTC
++++ t/77-freebsd-ports-test.t
+@@ -0,0 +1,33 @@
++#!/usr/bin/env perl
++
++# Conduct tests to address issues specific to the port:
++#
++# - Fix mismatches in relative file paths within the test target
++#   directory ($WRKSRC) used by 'make test', and apply the fixes to the
++#   existing tests.
++#
++# - Verify that the port does not reference the latest list.
++#
++#   - Compare the latest list with the built-in list.
++#
++#   - Detect unintended use of the latest list by testing a suffix such as
++#     zabc.net, an entry in the latest list that is not present in the
++#     built-in list.
++#
++#[notes]
++# the latest list:   installed public suffix list
++# the built-in list: default or embedded public suffix list
++
++use strict;
++use warnings;
++use Test::More;
++use Domain::PublicSuffix;
++
++my $ps = Domain::PublicSuffix->new({
++    'dataFile' => 't/effective_tld_names.dat'
++});
++   $ps->get_root_domain('zabc.net');
++
++is($ps->suffix, 'net', 'default ok');
++
++done_testing();
diff --git a/dns/p5-Domain-PublicSuffix/pkg-descr b/dns/p5-Domain-PublicSuffix/pkg-descr
new file mode 100644
index 000000000000..615bfcd780a5
--- /dev/null
+++ b/dns/p5-Domain-PublicSuffix/pkg-descr
@@ -0,0 +1,9 @@
+A perl module to parse a domain down to the root TLD utilizing the
+Mozilla Public Suffix List.
+
+This module utilizes the "public_suffix_list.dat" or "effective_tld_names.dat"
+provided by Mozilla as a way to effectively reduce a fully qualified
+domain name down to the absolute root. The Mozilla PublicSuffix file
+is an open source, fully documented format that shows absolute root
+TLDs, primarily for Mozilla's browser products to be able to determine
+how far a cookie's security boundaries go.
diff --git a/dns/p5-Domain-PublicSuffix/pkg-plist b/dns/p5-Domain-PublicSuffix/pkg-plist
new file mode 100644
index 000000000000..4397f4c7e494
--- /dev/null
+++ b/dns/p5-Domain-PublicSuffix/pkg-plist
@@ -0,0 +1,6 @@
+bin/get_root_domain
+%%SITE_PERL%%/Domain/PublicSuffix.pm
+%%SITE_PERL%%/Domain/PublicSuffix/Default.pm
+%%PERL5_MAN1%%/get_root_domain.1.gz
+%%PERL5_MAN3%%/Domain::PublicSuffix.3.gz
+%%PERL5_MAN3%%/Domain::PublicSuffix::Default.3.gz