You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The regex begins with {1,7}::, then {1,6}::{1}, then {1,5}::{1,2}, ..., and finally {1}::{1,6} and ::{1,7}. For A099::09C0:876A:130B, it stops when seeing A099:: (corresponds to {1,7}::). But it should match {1}::{1,6}.
Solution
Reverse the order of patterns with ::
i.e. ([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)
-> :((:[0-9a-fA-F]{1,4}){1,7}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:
Invalid address with multiple ::
Root Cause
\b treats colon : as a non-word character. Consequently, 1:, :2 and e: in 2001::25de::cade are consider word boundary.
Solution
Replace \b with a look-around which denies :
i.e. \b......\b -> (?<![\w:])......(?![\w:])
The text was updated successfully, but these errors were encountered:
Describe the bug
The regex doesn't work correctly on ipv6 with double colons
::
::
::
To Reproduce
Fixes
Valid address with
::
Root Cause
The regex begins with
{1,7}::
, then{1,6}::{1}
, then{1,5}::{1,2}
, ..., and finally{1}::{1,6}
and::{1,7}
. ForA099::09C0:876A:130B
, it stops when seeingA099::
(corresponds to{1,7}::
). But it should match{1}::{1,6}
.Solution
Reverse the order of patterns with
::
i.e.
([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)
->
:((:[0-9a-fA-F]{1,4}){1,7}|:)|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:
Invalid address with multiple
::
Root Cause
\b
treats colon:
as a non-word character. Consequently,1:
,:2
ande:
in2001::25de::cade
are consider word boundary.Solution
Replace
\b
with a look-around which denies:
i.e.
\b......\b
->(?<![\w:])......(?![\w:])
The text was updated successfully, but these errors were encountered: