Skip to content

Validate IP slice values before appending or replacing - #513

Merged
tomasaschan merged 1 commit into
spf13:masterfrom
agammann:fix-ip-slice-value-validation
Sep 21, 2026
Merged

tomasaschan merged 1 commit into
spf13:masterfrom
agammann:fix-ip-slice-value-validation

Conversation

@agammann

Copy link
Copy Markdown

IPSlice rejects invalid addresses through Set, but its SliceValue.Append and SliceValue.Replace methods currently report success and insert nil IPs. A failed replacement also discards the previous valid values.

Make the shared conversion helper return an error for an invalid address. Both operations validate before mutating the destination, matching the other numeric slice implementations. Add tests for invalid append, a partially valid replacement, unchanged state on error, and valid IPv4/IPv6 inputs with surrounding whitespace.

Validation on Windows with Go 1.27.1: both invalid-input regressions fail before the fix; go test ./... and go vet ./... pass after it.

@CLAassistant

CLAassistant commented Sep 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@tomasaschan
tomasaschan merged commit c966cfe into spf13:master Sep 21, 2026
8 checks passed
@tomasaschan

Copy link
Copy Markdown
Collaborator

Thanks!

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.

3 participants