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

allowLeadingZeros too strict? #20

Closed
mblaze opened this issue May 14, 2019 · 3 comments
Closed

allowLeadingZeros too strict? #20

mblaze opened this issue May 14, 2019 · 3 comments

Comments

@mblaze
Copy link

mblaze commented May 14, 2019

val Optionsv4 = new IPv4AddressStringParameters(
  false,
  false,
  false,
  RangeParameters.NO_RANGE,
  false,
  false,
  false,
  false,
  false,
  false,
  null)

val Optionsv6 = new IPv6AddressStringParameters(
  true,
  false,
  false,
  false,
  new IPAddressStringParameters.Builder().toParams,
  false,
  false,
  RangeParameters.NO_RANGE,
  false,
  false,
  null)

val Options = new IPAddressStringParameters(
  false,
  false,
  false,
  false,
  false,
  false,
  false,
  true,
  true,
  Optionsv4,
  Optionsv6)


new IPAddressString("1.2.0.1", Options).toAddress()

I expected this to work but it throws

inet.ipaddr.AddressStringException: 1.2.0.1 IP Address error: segment value starts with zero
	at inet.ipaddr.format.validate.Validator.validateAddress(scratch_198:622)
	at inet.ipaddr.format.validate.Validator.validateIPAddress(scratch_198:166)
	at inet.ipaddr.format.validate.Validator.validateAddress(scratch_198:134)
	at inet.ipaddr.IPAddressString.validate(scratch_198:453)
	at inet.ipaddr.IPAddressString.validate(scratch_198:402)
	at inet.ipaddr.IPAddressString.toAddress(scratch_198:765)
	at #worksheet#.get$$instance$$res0(scratch_198:46)
	at #worksheet#.#worksheet#(scratch_198:70)

I believe that there is a problem with allowLeadingZeros option because when it is set to true this example no longer throws. However, this has a side-effect of allowing addresses like 01.02.0.01 which I do not want.

@seancfoley
Copy link
Owner

seancfoley commented May 14, 2019

Yes, your test case confirms a bug in the leading zeros validation for IPv4, it was introduced with this commit:
646220c
and so the bug is in master, v5 branch v5.0.0 and up, v4 branch v4.2.0 and up.

@seancfoley
Copy link
Owner

The latest in branches master (the branch used for v5) and v4 have a fix for this. Will be doing a release with the fix soon.

@seancfoley
Copy link
Owner

This is fixed in versions 4.3.1 and 5.1.0.

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