urlapi: fix support for address scope in IPv6 numerical addresses
authorDaniel Stenberg <daniel@haxx.se>
Fri, 21 Sep 2018 06:17:39 +0000 (08:17 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 21 Sep 2018 09:19:14 +0000 (11:19 +0200)
Closes #3024

lib/urlapi-int.h
lib/urlapi.c
tests/libtest/lib1560.c

index 7ac09fdb5e06fbb0ef719117fec0ff455361ff98..a5bb8ea0be3783e8fc2e8a7b93e71027dd162933 100644 (file)
  *
  ***************************************************************************/
 #include "curl_setup.h"
+/* scheme is not URL encoded, the longest libcurl supported ones are 6
+   letters */
+#define MAX_SCHEME_LEN 8
+
 bool Curl_is_absolute_url(const char *url, char *scheme, size_t buflen);
 char *Curl_concat_url(const char *base, const char *relurl);
 size_t Curl_strlen_url(const char *url, bool relative);
index ef565d98d8b6a10378a88a8ca56ff30a5e2eee25..ff58a69cc4af4fc9a54c13a390e2fc0f501c17ba 100644 (file)
@@ -53,10 +53,6 @@ struct Curl_URL {
 
 #define DEFAULT_SCHEME "https"
 
-/* scheme is not URL encoded, the longest libcurl supported ones are 6
-   letters */
-#define MAX_SCHEME_LEN 8
-
 static void free_urlhandle(struct Curl_URL *u)
 {
   free(u->scheme);
@@ -480,7 +476,7 @@ static CURLUcode parse_port(struct Curl_URL *u, char *hostname)
   char endbracket;
   int len;
 
-  if((1 == sscanf(hostname, "[%*45[0123456789abcdefABCDEF:.]%c%n",
+  if((1 == sscanf(hostname, "[%*45[0123456789abcdefABCDEF:.%%]%c%n",
                   &endbracket, &len)) &&
      (']' == endbracket)) {
     /* this is a RFC2732-style specified IP-address */
@@ -561,7 +557,7 @@ static CURLUcode hostname_check(char *hostname, unsigned int flags)
 
   if(hostname[0] == '[') {
     hostname++;
-    l = "0123456789abcdefABCDEF::.";
+    l = "0123456789abcdefABCDEF::.%";
     hlen -= 2;
   }
 
index 224cb880fa36859e892d37364a09df04e215386b..7a5be812aba35362413a83aeba51af25ae48efd3 100644 (file)
@@ -128,6 +128,9 @@ struct querycase {
 };
 
 static struct testcase get_parts_list[] ={
+  {"https://[::1%252]:1234",
+   "https | [11] | [12] | [13] | [::1%252] | 1234 | / | [16] | [17]",
+   CURLU_DEFAULT_SCHEME, 0, CURLUE_OK},
   {"https://127.0.0.1:443",
    "https | [11] | [12] | [13] | 127.0.0.1 | [15] | / | [16] | [17]",
    0, CURLU_NO_DEFAULT_PORT, CURLUE_OK},