Salvador Fandino Garcia via RT wrote:
Show quoted textThanks for the reply.
I understand your thinking, and I have of course already implemented my
own workaround, but can't help but think that this is going to cause
other people problems in production. There should at least be some
clearer explanation of the thinking here, or perhaps two regexps to
choose from, one including and one excluding "::". Not everyone is at
home in regexp syntax, which is why your library will be so useful.
There are already so many examples of bad regexps out there on the web.
I have contacted the authors of rfc5952 about this specific case.
https://tools.ietf.org/html/rfc5952#section-4.2.1 says you must always
shorten an address as far as possible when applying "::".
That means the all zeros address 0000:0000:0000:0000:0000:0000:0000:0000
gets shortened to "::"
But if you then try to expand "::" back to
0000:0000:0000:0000:0000:0000:0000:0000 you have a problem.
RFC5952 would seem to suggest that :: is valid and should map back to
0000:0000:0000:0000:0000:0000:0000:0000
RFC2373 would suggest that "::" is only partially valid and corresponds
to the unspecified address XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX hence
your regexp says that this is an invalid IPv6 address.
This sort of ambiguity in the standards might just explain why so many
people have problems adding a default route to ::/0 in their systems,
and instead have to use 2001::/3, which of course is only a route for
IPv6 unicast traffic. It's not as though the default route is a rare use
case. Almost every end user system has one, and most routers too.
I think it is important that all well-used IPv6 libraries make the same
assumptions and work the same way, especially in this case.
I'll let you know how/if they respond.