]> git.kaiwu.me - nginx.git/commitdiff
Realip: allowed square brackets with portless IPv6 address.
authorRoman Arutyunyan <arut@nginx.com>
Mon, 11 Nov 2024 18:28:30 +0000 (22:28 +0400)
committerRoman Arutyunyan <arutyunyan.roman@gmail.com>
Tue, 26 Nov 2024 14:27:07 +0000 (18:27 +0400)
When client address is received, IPv6 address could be specified without
square brackets and without port, as well as both with the brackets and
port.  The change allows IPv6 in square brackets and no port, which was
previously considered an error.  This format conforms to RFC 3986.

The change also affects proxy_bind and friends.

src/core/ngx_inet.c

index acb2ef48a1e943f2d26d1eca438a67ab44e0c436..2233e617bb49bdb7a36a5d330dfc486f7dae3e97 100644 (file)
@@ -639,7 +639,11 @@ ngx_parse_addr_port(ngx_pool_t *pool, ngx_addr_t *addr, u_char *text,
 
         p = ngx_strlchr(text, last, ']');
 
-        if (p == NULL || p == last - 1 || *++p != ':') {
+        if (p == last - 1) {
+            return ngx_parse_addr(pool, addr, text + 1, len - 2);
+        }
+
+        if (p == NULL || *++p != ':') {
             return NGX_DECLINED;
         }