akalongman / akalongman/php-ip-tools

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

Đang mở
#8 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
147
Fork
10
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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);
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.