php-whois icon indicating copy to clipboard operation
php-whois copied to clipboard

Empty data values in `Iodev\Whois\Modules\Tld\TldInfo`

Open deryckoe opened this issue 9 months ago • 1 comments

PHP-Whois version: 4.1
PHP version: 8.3
Operating System: macOS

Description

When querying domain information using php-whois, the #dataDefault array in Iodev\Whois\Modules\Tld\TldInfo appears to be empty, even though the actual WHOIS response contains valid data. As a result, critical domain details such as "domainName", "creationDate", "expirationDate", and "owner" are not populated in #dataDefault.

However, when checking $info->response->data['text'], the correct data is present in the raw WHOIS response, suggesting that the issue might be related to parsing or mapping.

How to reproduce

Run the following PHP code:

use Iodev\Whois\Factory;

$whois = Factory::get()->createWhois();
$domain = "pucobre.cl";
$info = $whois->loadDomainInfo($domain);

var_dump($info);

Expected behavior

The parsed WHOIS information should populate all fields, including "domainName", "creationDate", "expirationDate", and "owner".

Actual behavior

Relevant fields in data remain empty:

#data: [
      "parserType" => "common",
      "domainName" => "pucobre.cl",
      "whoisServer" => "",
      "nameServers" => [
        "ns.pucobre.cl",
        "ns2.pucobre.cl",
        "secundario.nic.cl",
      ],
      "dnssec" => "",
      "creationDate" => 0,
      "expirationDate" => 0,
      "updatedDate" => "",
      "owner" => "Sociedad Punta del Cobre",
      "registrar" => "NIC Chile",
      "states" => [],
    ],

WHOIS Response Data

#response: Iodev\Whois\Modules\Tld\TldResponse {#2983
    #data: [
        "domain" => "pucobre.cl",
        "host" => "whois.nic.cl",
        "query" => "pucobre.cl\r\n",
        "text" => """
          %%\n
          %% This is the NIC Chile Whois server (whois.nic.cl).\n
          %%\n
          %% Rights restricted by copyright.\n
          %% See https://www.nic.cl/normativa/politica-publicacion-de-datos-cl.pdf\n
          %%\n
          \n
          Domain name: pucobre.cl\n
          Registrant name: Sociedad Punta del Cobre\n
          Registrant organisation: \n
          Registrar name: NIC Chile\n
          Registrar URL: https://www.nic.cl\n
          Creation date: 2001-01-08 21:05:28 CLST\n
          Expiration date: 2026-02-04 18:05:02 CLST\n
          Name server: ns.pucobre.cl (200.54.42.139)\n
          Name server: ns2.pucobre.cl (200.54.42.131)\n
          Name server: secundario.nic.cl\n
          \n
          %%\n
          %% For communication with domain contacts please use website.\n
          %% See https://www.nic.cl/registry/Whois.do?d=pucobre.cl\n
          %%\n
          """,
    ],
}

Possible Solution

  • The parser might not be correctly mapping the extracted data to #dataDefault.
  • This could be specific to the .cl TLD parser.
  • Updating or improving the regular expressions used for extracting data might help resolve the issue.

Additional context

  • Registrar: NIC Chile
  • Full WHOIS response (sanitized for brevity):
Domain name: pucobre.cl
Registrant name: Sociedad Punta del Cobre
Registrar name: NIC Chile
Creation date: 2001-01-08 21:05:28 CLST
Expiration date: 2026-02-04 18:05:02 CLST
Name server: ns.pucobre.cl (200.54.42.139)
Name server: ns2.pucobre.cl (200.54.42.131)
Name server: secundario.nic.cl

deryckoe avatar Feb 17 '25 20:02 deryckoe

CLST is not supported as a valid time zone. That may be the source of the problem. I wrote an alternative parser for .cl domains only, which gets the result in plain text, replaces CLST with CLS and then parses the data again. It works as follows.

deryckoe avatar Feb 17 '25 20:02 deryckoe