Skip to content

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

@noplanman

Description

@noplanman

When passing an empty string as the IP like this:

$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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions