Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of domain free response of .nl whois #138

Open
tofra opened this issue Apr 4, 2021 · 4 comments
Open

Incorrect handling of domain free response of .nl whois #138

tofra opened this issue Apr 4, 2021 · 4 comments

Comments

@tofra
Copy link

tofra commented Apr 4, 2021

PHP-Whois version: 4.0.0

PHP version: 7.4.13

Description
I'm searching if a .nl domain is free, and php-whois isn't able to correctly tell me if it's free. The things I observe is that when you too often do a whois request, the server response with "you have reached the limit of requests per second" (not the exact text), php-whois will return null when doing $whois->loadDomainInfo('notanexistingdomain.nl'). But it also returns null when the domain is free.
Also it will always do two requests to the whoisAPI, one with $query notanexistingdomain.nl and the second one with =notanexistingdomain.nl
The API returns notexistingnldomain.nl is free on the first request, and then the second request (which is initiated from https://github.com/io-developer/php-whois/blob/master/src/Iodev/Whois/Modules/Tld/TldModule.php#L210) with $query =notanexistingdomain.nl which get the response of the API Error: invalid domain name

How to reproduce
$result = $whois->loadDomainInfo('notanexistingdomain.nl'). It should not return null, and it should not execute 2 requests (aka should not come here https://github.com/io-developer/php-whois/blob/master/src/Iodev/Whois/Modules/Tld/TldModule.php#L210)

@io-developer
Copy link
Owner

Note:

    ["text"]=>
    string(74) "whois.domain-registry.nl: maximum number of requests per second exceeded
"

@tofra
Copy link
Author

tofra commented Oct 13, 2021

@io-developer Can you please guide me where I should look to fix it, so I can create a PR? My issue is the same like mentioned in #132 (comment)

I assume that we need to build something that will throw an exception when the "text" matches a specific text (like maximum number of requests per second exceeded)

@tofra
Copy link
Author

tofra commented Oct 13, 2021

Should we create a new Tld\Parser? To handle "error codes", and then throw exception?

@bessone
Copy link
Contributor

bessone commented Nov 25, 2021

At the moment a check is done on validateResponse method on loaders:

private function validateResponse($text)

private function validateResponse($text)

but the regular expression probably refers to the message of a single TLD, it should be extended to handle more cases of whois servers error messages, quite precisely to avoid false positives.

There are some regexps in the json and others in the PHP code, a more complete refactoring should put them all in one place, but IMHO that's too much work given the few developers on the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants