jeremykendall / php-domain-parser

Public Suffix List based domain parsing implemented in PHP
MIT License
1.16k stars 128 forks source link

Incorrect suffix extraction on public suffix #332

Closed mehrdadep closed 1 year ago

mehrdadep commented 2 years ago

Issue summary

Incorrect public suffix extraction. Referencing this list for public suffix we know that the eu.org is a suffix but the code below returns org. Is there something that I'm missing?

System informations

Information Description
Pdp version 6.1.1
PHP version 8.1
OS Platform Linux 5.19.0-76051900-generic

Standalone code, or another way to reproduce the problem

use Pdp\Rules;
use Pdp\Domain;

// The link is downloaded to this relative path
$publicSuffixList = Rules::fromPath('public.dat');
$domain = Domain::fromIDNA2008('test.eu.org');

$result = $publicSuffixList->resolve($domain)->suffix()->toString();

// print "org"

Expected result

Actual result

nyamsprod commented 2 years ago

@mehrdadep thanks for using the library.

I believe the package is behaving as expected. Aren't you making a mistake between the suffix and the registrable domain part ?

eu.org is the registrable domain (the part of the domain against which you need to register your domain. for instance you can buy test.eu.org.

The suffix is something else. Please read the documentation of check for more information on the internet.

mehrdadep commented 2 years ago

Yes, you're right. I forget to check the beginning of the private domains section

mehrdadep commented 2 years ago

Based on the behavior of some of the node packages like psl and parse-domain, either this package is not working as expected or those two.

nyamsprod commented 2 years ago

@mehrdadep I have no knowledge on those package so you should

mehrdadep commented 1 year ago

Hi there again, reopening this issue because right now the packages act differently from when I opened the issue. Running this now outputs eu.org

use Pdp\Rules;
use Pdp\Domain;

// The link is downloaded to this relative path
$publicSuffixList = Rules::fromPath('public.dat');
$domain = Domain::fromIDNA2008('test.eu.org');

$result = $publicSuffixList->resolve($domain)->suffix()->toString();
nyamsprod commented 1 year ago

@mehrdadep please refer to the package CHANGELOG. a patch version was released recently to fix an inconsistency into the private domain parsing.