]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
<rdar://problem/14243133> AirPrint: Printers with name containing certain characters...
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 25 Jun 2013 01:42:48 +0000 (01:42 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 25 Jun 2013 01:42:48 +0000 (01:42 +0000)
Support backquote (`) character and fix the IPv6 address detection code.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11052 a1ca3aef-8c08-0410-bb20-df032aa958be

CHANGES-1.6.txt
cups/http-support.c
cups/testhttp.c

index cf564acb1356a6853ce442b13fa96d815df1ce90..998b07a893310aa5e1b93aeebe26426ecb303421 100644 (file)
@@ -5,6 +5,8 @@ CHANGES IN CUPS V1.6.3
 
        - The configure script now prefers Clang over GCC.
        - Fixed a compile problem on AIX (STR #4307)
+       - Fixed a URI encoding issue for hostnames containing the ` (backquote)
+         character (<rdar://problem/14243133>)
        - Added support for RFC 6874's IPv6 link local address format in URIs
          (<rdar://problem/13979453>)
        - The USB backend could crash on libusb-based systems if USB was
index 3e974bc66d27f9be305400d9f20565598f164354..ba504823d7d353fe416d1e31b604c2ac20b5987d 100644 (file)
@@ -239,6 +239,9 @@ httpAssembleURI(
 
   if (host)
   {
+    const char *hostptr;               /* Pointer into hostname */
+    int                have_ipv6;              /* Do we have an IPv6 address? */
+
     if (username && *username)
     {
      /*
@@ -266,7 +269,17 @@ httpAssembleURI(
     * too...
     */
 
-    if (host[0] != '[' && strchr(host, ':') && !strstr(host, "._tcp"))
+    for (hostptr = host,
+             have_ipv6 = strchr(host, ':') && !strstr(host, "._tcp");
+         *hostptr && have_ipv6;
+         hostptr ++)
+      if (*hostptr != ':' && !isxdigit(*hostptr & 255))
+      {
+        have_ipv6 = *hostptr == '%';
+        break;
+      }
+
+    if (have_ipv6)
     {
      /*
       * We have a raw IPv6 address...
@@ -291,7 +304,7 @@ httpAssembleURI(
       else
       {
        /*
-        * We have a normal address, add "[" prefix...
+        * We have a normal (or RFC 6874 link-local) address, add "[" prefix...
        */
 
        if (ptr < end)
@@ -341,9 +354,12 @@ httpAssembleURI(
     else
     {
      /*
-      * Otherwise, just copy the host string...
+      * Otherwise, just copy the host string (the extra chars are not in the
+      * "reg-name" ABNF rule; anything <= SP or >= DEL plus % gets automatically
+      * percent-encoded.
       */
-      ptr = http_copy_encode(ptr, host, end, "<>{}|^:/?#[]@\\\"", NULL,
+
+      ptr = http_copy_encode(ptr, host, end, "\"#/:<>?@[\\]^`{|}", NULL,
                              encoding & HTTP_URI_CODING_HOSTNAME);
 
       if (!ptr)
@@ -1186,12 +1202,13 @@ httpSeparateURI(
       for (ptr = (char *)uri; *ptr; ptr ++)
         if (strchr(":?/", *ptr))
          break;
-        else if (!strchr("abcdefghijklmnopqrstuvwxyz"
-                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                        "0123456789"
-                        "-._~"
-                        "%"
-                        "!$&'()*+,;=\\", *ptr))
+        else if (!strchr("abcdefghijklmnopqrstuvwxyz"  /* unreserved */
+                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"   /* unreserved */
+                        "0123456789"                   /* unreserved */
+                        "-._~"                         /* unreserved */
+                        "%"                            /* pct-encoded */
+                        "!$&'()*+,;="                  /* sub-delims */
+                        "\\", *ptr))                   /* SMB domain */
        {
          *host = '\0';
          return (HTTP_URI_STATUS_BAD_HOSTNAME);
@@ -1284,8 +1301,9 @@ httpSeparateURI(
 
       char *resptr = resource + strlen(resource);
 
-      uri = http_copy_decode(resptr, uri, resourcelen - (int)(resptr - resource),
-                             NULL, decoding & HTTP_URI_CODING_QUERY);
+      uri = http_copy_decode(resptr, uri,
+                             resourcelen - (int)(resptr - resource), NULL,
+                             decoding & HTTP_URI_CODING_QUERY);
     }
   }
 
index 3599cea47d1104d94a7138e7c3b394fabb1d3d71..4d0ee474a48d2640afadac7fb9617be80da37d30 100644 (file)
@@ -121,6 +121,9 @@ static uri_test_t   uri_tests[] =   /* URI test data */
                          { HTTP_URI_STATUS_OK, "ipp://HP%20Officejet%204500%20G510n-z%20%40%20Will's%20MacBook%20Pro%2015%22._ipp._tcp.local./",
                            "ipp", "", "HP Officejet 4500 G510n-z @ Will's MacBook Pro 15\"._ipp._tcp.local.", "/", 631, 0,
                            HTTP_URI_CODING_MOST  },
+                         { HTTP_URI_STATUS_OK, "ipp://%22%23%2F%3A%3C%3E%3F%40%5B%5C%5D%5E%60%7B%7C%7D/",
+                           "ipp", "", "\"#/:<>?@[\\]^`{|}", "/", 631, 0,
+                           HTTP_URI_CODING_MOST  },
 
                          /* Missing scheme */
                          { HTTP_URI_STATUS_MISSING_SCHEME, "/path/to/file/index.html",
@@ -171,6 +174,9 @@ static uri_test_t   uri_tests[] =   /* URI test data */
                          { HTTP_URI_STATUS_BAD_HOSTNAME, "http://server with spaces/index.html",
                            "http", "", "", "", 80, 0,
                            HTTP_URI_CODING_MOST  },
+                         { HTTP_URI_STATUS_BAD_HOSTNAME, "ipp://\"#/:<>?@[\\]^`{|}/",
+                           "ipp", "", "", "", 631, 0,
+                           HTTP_URI_CODING_MOST  },
 
                          /* Bad port number */
                          { HTTP_URI_STATUS_BAD_PORT, "http://127.0.0.1:9999a/index.html",