akalongman / akalongman/php-ip-tools

isRemote() is not the same as !isLocal()

Offen
#8 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
PHP
Sterne
147
Forks
10
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

When passing an empty string as the IP like this:
```php
$ip = '';
$is_remote = Ip::isRemote($ip);
```

it returns `true`, even thought the IP itself is invalid.

This is because `isLocal()` returns `false` (due to the IP being invalid), and `isRemote()` simply switches the result to `true`.

Workaround:
```php
$ip = '';
$is_remote = Ip::isValid($ip) && Ip::isRemote($ip);
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.