From 5748ece401851de31961c066a8c6475fc38facb5 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 22 Sep 2023 14:04:52 -0300 Subject: [PATCH] Add support for `::13.1.68.3` Fix #9 --- src/isinetaddr6.c | 8 ++++++-- test/isinetaddr6_test.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/isinetaddr6.c b/src/isinetaddr6.c index b5ac714..6db4af8 100644 --- a/src/isinetaddr6.c +++ b/src/isinetaddr6.c @@ -27,8 +27,12 @@ isinetaddr6(const char *str) if (has_consecutive_chars(&str[i], SEP, 3)) { return 0; } else if (has_consecutive_chars(&str[i], SEP, 2)) { - char new_str[MAX_STRLEN]; - return isinetaddr6(expand(str, len, new_str, i)); + if (i == 0 && isinetaddr4(&str[3])) { + return 1; + } else { + char new_str[MAX_STRLEN]; + return isinetaddr6(expand(str, len, new_str, i)); + } } else if (str[i] == SEP) { digitlen = 0; } else if (isxdigit(str[i])) { diff --git a/test/isinetaddr6_test.c b/test/isinetaddr6_test.c index 9b81f89..82065f5 100644 --- a/test/isinetaddr6_test.c +++ b/test/isinetaddr6_test.c @@ -36,6 +36,7 @@ const char *valid[] = { "FF01::101", "::ffff:192.168.2.1", "::FFFF:192.168.2.1", + "::13.1.68.3", "::", "::1", };