Skip to content

Fix IPv4 format validator regex false positives#1909

Merged
lahma merged 1 commit intoRicoSuter:masterfrom
lahma:fix/ipv4-regex-escape-dot-1409
Mar 9, 2026
Merged

Fix IPv4 format validator regex false positives#1909
lahma merged 1 commit intoRicoSuter:masterfrom
lahma:fix/ipv4-regex-escape-dot-1409

Conversation

@lahma
Copy link
Copy Markdown
Collaborator

@lahma lahma commented Mar 8, 2026

Summary

  • Escape the dot character (.\.) in the IPv4 validation regex to match only literal dots
  • Previously, strings like "00:45:00.0" or "1:2:3:4" incorrectly passed IPv4 validation because the unescaped . matches any character
  • Added test cases for invalid inputs that were previously accepted

Fixes #1409

Test plan

  • Existing IPv4 tests continue to pass ("192.168.0.1" valid, "test" invalid)
  • New test: "00:45:00.0" correctly rejected
  • New test: "1:2:3:4" correctly rejected
  • New test: "256.1.1.1" correctly rejected

🤖 Generated with Claude Code

Escape dot character in regex to match literal dots only,
preventing strings like '00:45:00.0' from passing validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lahma lahma merged commit 7424d6c into RicoSuter:master Mar 9, 2026
2 checks passed
@lahma lahma deleted the fix/ipv4-regex-escape-dot-1409 branch March 9, 2026 06:43
RicoSuter added a commit that referenced this pull request Mar 29, 2026
Migrate new FormatIpV4Tests from master (JValue -> JsonValue.Create)
after merging Fix IPv4 format validator regex false positives (#1909).
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.

IPv4 validation regex validates faulty ip adresses

1 participant