Skip to content

Minour IP4 "isValid" or "construct fromString" issue #23

Open
@aosenkidu

Description

@aosenkidu

Strictly speaking, this one is still correct:
isValid { _address.count == 4 && _address.all {|n| n is Num && n >= 0 && n <= 255 }}

But the way how the array is filled assumes all parts of the string are in decimal format:

construct fromString(s) {
    _address = s.split(".").map { |n| Num.fromString(n) }
  }

However an IP address like this: 168.011.012.013 is not decimal. The 3 parts starting with a 0 are supposed to be interpreted as octal numbers.

So strictly speaking you construct a "valid IP address" but it is not the one, a proper IP stack would construct.

No worries: that usage is extremely rare ... and there are (plenty?) IP stacks that do it wrong, too :P

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