svn commit: r1928016 - apr/apr/trunk/uri

[email protected]
Newsgroups gmane.comp.apache.apr.cvs
Message-ID <175620102871.2089865.12273034828375147245@svn02-us-east.apache.org>
Author: rpluem
Date: Tue Aug 26 09:37:08 2025
New Revision: 1928016

Log:
* Only look for a scope id inside the IPv6 address not ouside which means beyond the closing ']'

Modified:
   apr/apr/trunk/uri/apr_uri.c

Modified: apr/apr/trunk/uri/apr_uri.c
==============================================================================
--- apr/apr/trunk/uri/apr_uri.c	Tue Aug 26 08:30:17 2025	(r1928015)
+++ apr/apr/trunk/uri/apr_uri.c	Tue Aug 26 09:37:08 2025	(r1928016)
@@ -124,7 +124,7 @@ static void percent_decode_scope_zone_id
     memmove(hostname + offset + 1, hostname + offset + 3, len - offset - 2);
 }
 
-static char * percent_encode_scope_zone_id(apr_pool_t *p, apr_uri_t const *uptr)
+static char *percent_encode_scope_zone_id(apr_pool_t *p, apr_uri_t const *uptr)
 {
     /* Inverse to the logic in the decode function, we need to encode the first
      * percent sign we encounter (if any).
@@ -945,9 +945,17 @@ deal_with_host:
          * unescape that.
          */
         if (*hostinfo == '[') {
+            apr_status_t err;
+
+            v6_offset1 = 1;
+            v6_offset2 = 2;
+            s = memchr(hostinfo, ']', uri - hostinfo);
+            if (s == NULL) {
+                return APR_EGENERAL;
+            }
+
             /* zone identifier */
-            apr_status_t err = detect_scope_zone_id(&have_zone_id, hostinfo,
-                                                    uri - hostinfo);
+            err = detect_scope_zone_id(&have_zone_id, hostinfo + 1, s - hostinfo - 1);
             /* FIXME: Ignore APR_EINVAL (invalid escaped character) for now as
              * old code may rely on it silently getting ignored?
              */
@@ -956,12 +964,6 @@ deal_with_host:
             }
 
             /* Port */
-            v6_offset1 = 1;
-            v6_offset2 = 2;
-            s = memchr(hostinfo, ']', uri - hostinfo);
-            if (s == NULL) {
-                return APR_EGENERAL;
-            }
             if (*++s != ':') {
                 s = NULL; /* no port */
             }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.