Skip to content

Comments

Fix incomplete IPv6 regex patterns for compressed addresses#4187

Closed
Copilot wants to merge 2 commits intofix-url-regex-filterfrom
copilot/sub-pr-4185
Closed

Fix incomplete IPv6 regex patterns for compressed addresses#4187
Copilot wants to merge 2 commits intofix-url-regex-filterfrom
copilot/sub-pr-4185

Conversation

Copy link
Contributor

Copilot AI commented Dec 28, 2025

The IPv6 regex patterns failed to match valid compressed addresses when :: appears mid-address with multiple segments on both sides (e.g., fe80:1:2::3:4:5:6).

Changes

  • Comprehensive compression handling: Added patterns for all valid :: positions (1-6 groups before, 1-6 groups after) instead of the previous limited set
  • Pattern ordering: Reordered alternatives from most-to-least specific to prevent premature partial matches (e.g., 2001:db8:: matching when input is 2001:db8::1)
  • Consistency: Updated both bracketed [IPv6] and non-bracketed patterns

Implementation

The fix enumerates all valid IPv6 compression positions. For example:

// Old: Only matched specific compression patterns
"(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}" // Incomplete

// New: Handles all compression positions
"(?:[0-9a-fA-F]{1,4}:){6}:[0-9a-fA-F]{1,4}|"      // 6 groups :: 1 group
"(?:[0-9a-fA-F]{1,4}:){5}:(?:[0-9a-fA-F]{1,4}:)?[0-9a-fA-F]{1,4}|" // 5 :: 1-2
"(?:[0-9a-fA-F]{1,4}:){4}:(?:[0-9a-fA-F]{1,4}:){0,2}[0-9a-fA-F]{1,4}|" // 4 :: 1-3
// ... (continues for all valid combinations)

Note: In (?:[0-9a-fA-F]{1,4}:){6}:, the quantified group already includes trailing colons (matching a:b:c:d:e:f:), so a single : suffix correctly produces ::.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…dresses

Co-authored-by: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on UrlPattern update Fix incomplete IPv6 regex patterns for compressed addresses Dec 28, 2025
@jjw24 jjw24 deleted the copilot/sub-pr-4185 branch February 21, 2026 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 min review bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants