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

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

Open
aosenkidu opened this issue Feb 24, 2023 · 1 comment
Open

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

aosenkidu opened this issue Feb 24, 2023 · 1 comment

Comments

@aosenkidu
Copy link

aosenkidu commented Feb 24, 2023

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

@joshgoebel
Copy link
Owner

A patch would be accepted, but right now I'm not sure when I'll ever find the time to finish that branch.

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

2 participants