io-developer / php-whois

PHP WHOIS provides parsed and raw whois lookup of domains and ASN routes. PHP 8.0 compatible (5.4+ old versions)
MIT License
438 stars 117 forks source link

TypeError: trim(): Argument #1 ($string) must be of type string, array given #162

Closed lucaros97 closed 1 year ago

lucaros97 commented 3 years ago

PHP-Whois version: 4.1.3

PHP-Whois version: 4.1.3

PHP version: 8.0.6

Description
Even if related to #153 I got the same error with a com.tw domain with the 4.1.3 which should have fixed that. TypeError: trim(): Argument #1 ($string) must be of type string, array given

How to reproduce
Example domain: https://cabco.com.tw

lucaros97 commented 2 years ago

Any update on this? @bessone @io-developer

io-developer commented 2 years ago

Bug confirmed ./bin/php-whois info cabco.com.tw

bessone commented 2 years ago

Given the nature of whois .tw formatting, the current code fails to recognize and extract the data correctly, some examples with small differences:

Domain Name: cabco.com.tw
   Domain Status: ok
   Registrant:
      誠麗實業股份有限公司
      Charming & Beauty Co.,LTD
      CHARLES YU  cabco.yu@msa.hinet.net
      +886.228271901

      IF,NO 55,SEC 1,ZHIYUAN 1ST RD,BEITOU DIST., TAIPEI, TAIWAN,ROC
      none, Taiwan
      TW

   Administrative Contact:
      CHARLES YU  cabco.yu@msa.hinet.net
      +886.228271901

   Technical Contact:
      CHARLES YU  cabco.yu@msa.hinet.net
      +886.228271901

   Record expires on 2022-07-25 00:00:00 (UTC+8)
   Record created on 2002-07-07 01:46:06 (UTC+8)

   Domain servers in listed order:
      vdns3.seed.net.tw
      vdns4.seed.net.tw

Registration Service Provider: SEEDNET
Registration Service URL: http://rs.seed.net.tw
Domain Name: google.com.tw
   Domain Status: clientUpdateProhibited,clientTransferProhibited,clientDeleteProhibited
   Registrant:

      Google Inc.
      DNS Admin  dns-admin@google.com
      +1.6502530000
      +1.6506188571
      1600 Amphitheatre Parkway
      Mountain View, CA
      US

   Administrative Contact:
      DNS Admin  dns-admin@google.com
      +1.6502530000
      +1.6506188571

   Technical Contact:
      DNS Admin  dns-admin@google.com
      +1.6502530000
      +1.6506188571

   Record expires on 2022-11-09 00:00:00 (UTC+8)
   Record created on 2000-08-29 10:22:50 (UTC+8)

   Domain servers in listed order:
      ns1.google.com
      ns2.google.com
      ns3.google.com
      ns4.google.com

Registration Service Provider: Markmonitor, Inc.
Registration Service URL: http://www.markmonitor.com/

Provided by Registry Services, LLC. Registry Gateway Services
Domain Name: vespalinecampaign.com.tw
   Domain Status: ok
   Registrant:
      Piaggio & C. S.p.A.
      Not displayed due to GDPR
      IT

   Administrative Contact:
      Not displayed due to GDPR

   Technical Contact:
      Not displayed due to GDPR

   Record expires on 2022-10-29 22:12:39 (UTC+8)
   Record created on 2021-10-29 22:12:39 (UTC+8)

   Domain servers in listed order:
      ns.barbero.de
      ns.barbero.asia
      ns.barbero.eu
      ns.barbero.us
      ns.barbero.uk

Registration Service Provider: 1API GmbH
Registration Service URL: http://www.1api.de/

Provided by Registry Services, LLC. Registry Gateway Services

I think it is necessary to work on the parsing code (and maybe on the regular expressions), unfortunately I do not know the library so thoroughly to work independently.

The error arises in the incorrect parsing in the method Iodev\Whois\Helpers\ParserHelper::linesToGroups() we have to dig here, without breaking everything else :grin:

io-developer commented 2 years ago

Error fixed. But .tw parsing is still incorrect. Have ho idea how to improve it for this moment