Skip to content

Conversation

@smaye81
Copy link
Contributor

@smaye81 smaye81 commented Apr 9, 2025

This ports the ipv6 fix from bufbuild/protovalidate-go#215.

For context see the description on the above PR. The summary is that this fixes the validation for some corner cases of IPv6 address validation. Namely:

  • Adds a check that an IPv6 address can't begin or end on a single colon.
  • Adds a check to fail-fast on invalid hextets.

@smaye81 smaye81 requested review from pkwarren and timostamm April 9, 2025 16:05
return false;
// this is an error condition, it means we found a string of more than
// four valid hex digits, which is invalid in ipv6 addresses.
throw new ParseException("invalid hex", this.index);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to use exceptions for control flow here, I'd throw an IllegalStateException here over a ParseException.

Suggested change
throw new ParseException("invalid hex", this.index);
throw new IllegalStateException("invalid hex");

@smaye81 smaye81 merged commit 38be4e6 into sayers/validation_upgrades Apr 16, 2025
3 checks passed
@smaye81 smaye81 deleted the sayers/ipv6_fix branch April 16, 2025 14:53
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

Successfully merging this pull request may close these issues.

2 participants