cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH 09/10] parse_proxy: Support RFC 6874

From: Till Maas <opensource_at_till.name>
Date: Sat, 15 Mar 2014 19:41:33 +0100

Allow IPv6 zone identifiers, i.e. URLs like 'http://[fe80::1%eth0]' for
proxies.

---
 lib/url.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/lib/url.c b/lib/url.c
index 6738eb0..96e9b64 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -4384,12 +4384,22 @@ static CURLcode parse_proxy(struct SessionHandle *data,
   /* start scanning for port number at this point */
   portptr = proxyptr;
 
-  /* detect and extract RFC2732-style IPv6-addresses */
+  /* detect and extract RFC6874-style IPv6-addresses */
   if(*proxyptr == '[') {
     char *ptr = ++proxyptr; /* advance beyond the initial bracket */
-    while(*ptr && (ISXDIGIT(*ptr) || (*ptr == ':') || (*ptr == '%') ||
-                   (*ptr == '.')))
+    while(*ptr && (ISXDIGIT(*ptr) || (*ptr == ':') || (*ptr == '.')))
       ptr++;
+    if(*ptr == '%') {
+      /* There might be a zone identifier */
+      if (strncmp("%25", ptr, 3) != 0) {
+        infof(data, "Please URL encode %% as %%25, see RFC 6874.\n");
+      }
+      ptr++;
+      /* Allow unresered characters as defined in RFC 3986 */
+      while(*ptr && (ISALPHA(*ptr) || ISXDIGIT(*ptr) || (*ptr == '-') ||
+                     (*ptr == '.') || (*ptr == '_') || (*ptr == '~')))
+        ptr++;
+    }
     if(*ptr == ']')
       /* yeps, it ended nicely with a bracket as well */
       *ptr++ = 0;
-- 
1.8.3.1
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-03-15