From 8cc2e5863cfdc93025b3b1d2012b8d22f446f254 Mon Sep 17 00:00:00 2001 From: Hans Adema Date: Sun, 31 Aug 2025 17:10:04 +0200 Subject: [PATCH 1/4] Fix TypeError in BlockParser::parseDate with fallback regex Fixes #220 --- src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php b/src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php index c2516a95..8a4b87bc 100644 --- a/src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php +++ b/src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php @@ -434,6 +434,17 @@ protected function parseDate( } } } + foreach ($sel->getAll() as $value) { + $strs = is_array($value) ? $value : [$value]; + foreach ($strs as $str) { + if ($str && preg_match($fallbackRegex, $str)) { + $time = DateHelper::parseDateInText($str); + if (!empty($time)) { + return $time; + } + } + } + } return 0; } From 5b09e4795ea8131bab9f8d8b81e0c6513380136f Mon Sep 17 00:00:00 2001 From: Hans Adema Date: Sun, 31 Aug 2025 17:17:53 +0200 Subject: [PATCH 2/4] Add test data --- .../parsing_data/.com/semihkoyuturk.com.json | 17 +++ .../parsing_data/.com/semihkoyuturk.com.txt | 131 ++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json create mode 100644 tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.txt diff --git a/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json new file mode 100644 index 00000000..6ed30395 --- /dev/null +++ b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json @@ -0,0 +1,17 @@ +{ + "domainName": "semihkoyuturk.com", + "whoisServer": "whois.apiname.com", + "nameServers": [ + "ns1.infinityfree.com", + "ns2.infinityfree.com" + ], + "dnssec": "unsigned", + "creationDate": "2016-03-25T19:40:34Z", + "expirationDate": "2026-03-25T19:40:34Z", + "updatedDate": "2025-06-01T10:30:25Z", + "states": [ + "clienttransferprohibited" + ], + "owner": "", + "registrar": "Atak Domain" +} diff --git a/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.txt b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.txt new file mode 100644 index 00000000..b749505c --- /dev/null +++ b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.txt @@ -0,0 +1,131 @@ + Domain Name: SEMIHKOYUTURK.COM + Registry Domain ID: 2015881728_DOMAIN_COM-VRSN + Registrar WHOIS Server: whois.apiname.com + Registrar URL: http://www.apiname.com + Updated Date: 2025-06-01T10:30:25Z + Creation Date: 2016-03-25T19:40:34Z + Registry Expiry Date: 2026-03-25T19:40:34Z + Registrar: Atak Domain Bilgi Teknolojileri A.S. + Registrar IANA ID: 1601 + Registrar Abuse Contact Email: domain@apiname.com + Registrar Abuse Contact Phone: +90.2623259222 + Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited + Name Server: NS1.INFINITYFREE.COM + Name Server: NS2.INFINITYFREE.COM + DNSSEC: unsigned + URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/ +>>> Last update of whois database: 2025-08-31T14:22:22Z <<< + +For more information on Whois status codes, please visit https://icann.org/epp + +NOTICE: The expiration date displayed in this record is the date the +registrar's sponsorship of the domain name registration in the registry is +currently set to expire. This date does not necessarily reflect the expiration +date of the domain name registrant's agreement with the sponsoring +registrar. Users may consult the sponsoring registrar's Whois database to +view the registrar's reported date of expiration for this registration. + +TERMS OF USE: You are not authorized to access or query our Whois +database through the use of electronic processes that are high-volume and +automated except as reasonably necessary to register domain names or +modify existing registrations; the Data in VeriSign Global Registry +Services' ("VeriSign") Whois database is provided by VeriSign for +information purposes only, and to assist persons in obtaining information +about or related to a domain name registration record. VeriSign does not +guarantee its accuracy. By submitting a Whois query, you agree to abide +by the following terms of use: You agree that you may use this Data only +for lawful purposes and that under no circumstances will you use this Data +to: (1) allow, enable, or otherwise support the transmission of mass +unsolicited, commercial advertising or solicitations via e-mail, telephone, +or facsimile; or (2) enable high volume, automated, electronic processes +that apply to VeriSign (or its computer systems). The compilation, +repackaging, dissemination or other use of this Data is expressly +prohibited without the prior written consent of VeriSign. You agree not to +use electronic processes that are automated and high-volume to access or +query the Whois database except as reasonably necessary to register +domain names or modify existing registrations. VeriSign reserves the right +to restrict your access to the Whois database in its sole discretion to ensure +operational stability. VeriSign may restrict or terminate your access to the +Whois database for failure to abide by these terms of use. VeriSign +reserves the right to modify these terms at any time. + +The Registry database contains ONLY .COM, .NET, .EDU domains and +Registrars. +Domain Name: semihkoyuturk.com +Registry Domain ID: 2015881728_DOMAIN_COM-VRSN +Registrar WHOIS Server: whois.apiname.com +Registrar URL: http://apiname.com +Updated Date: +Creation Date: +Registrar Registration Expiration Date: 2026-03-25T22:40:34Z +Registrar: Atak Domain +Registrar IANA ID: 1601 +Registrar Abuse Contact Email: domain@apiname.com +Registrar Abuse Contact Phone: +90.2623259222 +Reseller: G�zel Hosting +Domain Status: http://www.icann.org/epp#clientTransferProhibited +Registry Registrant ID: DNA-DN-17639910 +Registrant Name: Guzel Hosting Musteri +Registrant Organization: n/a +Registrant Street: Icerenkoy Mh. Ertac Sk. +Registrant Street: Ardil Is Merkezi 4/2 +Registrant Street: +Registrant City: Istanbul +Registrant State/Province: Atasehir +Registrant Postal Code: 34752 +Registrant Country: TR +Registrant Phone: +90.8508850558 +Registrant Phone Ext: +Registrant Fax: +Registrant Fax Ext: +Registrant Email: bildirim@guzel.net.tr +Registry Admin ID: DNA-DN-17639910 +Admin Name: Guzel Hosting Musteri +Admin Organization: n/a +Admin Street: Icerenkoy Mh. Ertac Sk. +Admin Street: Ardil Is Merkezi 4/2 +Admin Street: +Admin City: Istanbul +Admin State/Province: Atasehir +Admin Postal Code: 34752 +Admin Country: TR +Admin Phone: +90.8508850558 +Admin Phone Ext: +Admin Fax: +Admin Fax Ext: +Admin Email: bildirim@guzel.net.tr +Registry Tech ID: DNA-DN-17639910 +Tech Name: Guzel Hosting Musteri +Tech Organization: n/a +Tech Street: Icerenkoy Mh. Ertac Sk. +Tech Street: Ardil Is Merkezi 4/2 +Tech Street: +Tech City: Istanbul +Tech State/Province: Atasehir +Tech Postal Code: 34752 +Tech Country: TR +Tech Phone: +90.8508850558 +Tech Phone Ext: +Tech Fax: +Tech Fax Ext: +Tech Email: bildirim@guzel.net.tr +Name Server: ns1.infinityfree.com +Name Server: ns2.infinityfree.com +DNSSEC: unsigned +URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/ +>>> Last update of WHOIS database: 2025-08-25T02:32:48.670Z <<< + +For more information on Whois status codes, please visit https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en. +This data is provided for information purposes, and to assist persons +obtaining information about or related to domain name registration +records. We do not guarantee its accuracy. +By submitting a WHOIS query, you agree that you will use this data +only for lawful purposes and that, under no circumstances, you will +use this data to +1) allow, enable, or otherwise support the transmission of mass +unsolicited, commercial advertising or solicitations via E-mail +(spam); or +2) enable high volume, automated, electronic processes that apply +to this WHOIS server. +These terms may be changed without prior notice. +By submitting this query, you agree to abide by this policy. From 3a38eccbb15701350b2a51df3951fb6b6e001899 Mon Sep 17 00:00:00 2001 From: Hans Adema Date: Sun, 31 Aug 2025 17:24:40 +0200 Subject: [PATCH 3/4] Load in text, fix code --- src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php | 8 -------- tests/Iodev/Whois/Modules/Tld/TldParsingTest.php | 1 + .../Modules/Tld/parsing_data/.com/semihkoyuturk.com.json | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php b/src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php index 8a4b87bc..2bf2f07b 100644 --- a/src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php +++ b/src/Iodev/Whois/Modules/Tld/Parsers/BlockParser.php @@ -426,14 +426,6 @@ protected function parseDate( if (empty($fallbackRegex)) { return 0; } - foreach ($sel->getAll() as $str) { - if ($str && preg_match($fallbackRegex, $str)) { - $time = DateHelper::parseDateInText($str); - if (!empty($time)) { - return $time; - } - } - } foreach ($sel->getAll() as $value) { $strs = is_array($value) ? $value : [$value]; foreach ($strs as $str) { diff --git a/tests/Iodev/Whois/Modules/Tld/TldParsingTest.php b/tests/Iodev/Whois/Modules/Tld/TldParsingTest.php index 48ae48dd..4876b412 100644 --- a/tests/Iodev/Whois/Modules/Tld/TldParsingTest.php +++ b/tests/Iodev/Whois/Modules/Tld/TldParsingTest.php @@ -350,6 +350,7 @@ public function getTestData() [ "free.com", ".com/free.txt", null ], [ "google.com", ".com/google.com.txt", ".com/google.com.json" ], [ "google.com", ".com/google.com_registrar_whois.txt", ".com/google.com_registrar_whois.json" ], + [ "semihkoyuturk.com", ".com/semihkoyuturk.com.txt", ".com/semihkoyuturk.com.json" ], // .CR [ "free.cr", ".cr/free.txt", null ], diff --git a/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json index 6ed30395..2c1e9ca9 100644 --- a/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json +++ b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json @@ -12,6 +12,6 @@ "states": [ "clienttransferprohibited" ], - "owner": "", - "registrar": "Atak Domain" + "owner": "n/a", + "registrar": "Atak Domain Bilgi Teknolojileri A.S." } From ed416ff1c92d28393b1a1cada7f8dea18265c210 Mon Sep 17 00:00:00 2001 From: Hans Adema Date: Sun, 31 Aug 2025 17:44:53 +0200 Subject: [PATCH 4/4] Fix test fixtures to reproduce issue --- .../parsing_data/.com/semihkoyuturk.com.json | 12 ++-- .../parsing_data/.com/semihkoyuturk.com.txt | 55 +------------------ 2 files changed, 6 insertions(+), 61 deletions(-) diff --git a/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json index 2c1e9ca9..a635b744 100644 --- a/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json +++ b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.json @@ -6,12 +6,10 @@ "ns2.infinityfree.com" ], "dnssec": "unsigned", - "creationDate": "2016-03-25T19:40:34Z", - "expirationDate": "2026-03-25T19:40:34Z", - "updatedDate": "2025-06-01T10:30:25Z", - "states": [ - "clienttransferprohibited" - ], + "creationDate": "", + "expirationDate": "2026-03-25T22:40:34Z", + "updatedDate": "", + "states": [], "owner": "n/a", - "registrar": "Atak Domain Bilgi Teknolojileri A.S." + "registrar": "Atak Domain" } diff --git a/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.txt b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.txt index b749505c..cbdcd689 100644 --- a/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.txt +++ b/tests/Iodev/Whois/Modules/Tld/parsing_data/.com/semihkoyuturk.com.txt @@ -1,56 +1,3 @@ - Domain Name: SEMIHKOYUTURK.COM - Registry Domain ID: 2015881728_DOMAIN_COM-VRSN - Registrar WHOIS Server: whois.apiname.com - Registrar URL: http://www.apiname.com - Updated Date: 2025-06-01T10:30:25Z - Creation Date: 2016-03-25T19:40:34Z - Registry Expiry Date: 2026-03-25T19:40:34Z - Registrar: Atak Domain Bilgi Teknolojileri A.S. - Registrar IANA ID: 1601 - Registrar Abuse Contact Email: domain@apiname.com - Registrar Abuse Contact Phone: +90.2623259222 - Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited - Name Server: NS1.INFINITYFREE.COM - Name Server: NS2.INFINITYFREE.COM - DNSSEC: unsigned - URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/ ->>> Last update of whois database: 2025-08-31T14:22:22Z <<< - -For more information on Whois status codes, please visit https://icann.org/epp - -NOTICE: The expiration date displayed in this record is the date the -registrar's sponsorship of the domain name registration in the registry is -currently set to expire. This date does not necessarily reflect the expiration -date of the domain name registrant's agreement with the sponsoring -registrar. Users may consult the sponsoring registrar's Whois database to -view the registrar's reported date of expiration for this registration. - -TERMS OF USE: You are not authorized to access or query our Whois -database through the use of electronic processes that are high-volume and -automated except as reasonably necessary to register domain names or -modify existing registrations; the Data in VeriSign Global Registry -Services' ("VeriSign") Whois database is provided by VeriSign for -information purposes only, and to assist persons in obtaining information -about or related to a domain name registration record. VeriSign does not -guarantee its accuracy. By submitting a Whois query, you agree to abide -by the following terms of use: You agree that you may use this Data only -for lawful purposes and that under no circumstances will you use this Data -to: (1) allow, enable, or otherwise support the transmission of mass -unsolicited, commercial advertising or solicitations via e-mail, telephone, -or facsimile; or (2) enable high volume, automated, electronic processes -that apply to VeriSign (or its computer systems). The compilation, -repackaging, dissemination or other use of this Data is expressly -prohibited without the prior written consent of VeriSign. You agree not to -use electronic processes that are automated and high-volume to access or -query the Whois database except as reasonably necessary to register -domain names or modify existing registrations. VeriSign reserves the right -to restrict your access to the Whois database in its sole discretion to ensure -operational stability. VeriSign may restrict or terminate your access to the -Whois database for failure to abide by these terms of use. VeriSign -reserves the right to modify these terms at any time. - -The Registry database contains ONLY .COM, .NET, .EDU domains and -Registrars. Domain Name: semihkoyuturk.com Registry Domain ID: 2015881728_DOMAIN_COM-VRSN Registrar WHOIS Server: whois.apiname.com @@ -62,7 +9,7 @@ Registrar: Atak Domain Registrar IANA ID: 1601 Registrar Abuse Contact Email: domain@apiname.com Registrar Abuse Contact Phone: +90.2623259222 -Reseller: G�zel Hosting +Reseller: G?zel Hosting Domain Status: http://www.icann.org/epp#clientTransferProhibited Registry Registrant ID: DNA-DN-17639910 Registrant Name: Guzel Hosting Musteri