From: msweet Date: Tue, 25 Jun 2013 01:42:48 +0000 (+0000) Subject: AirPrint: Printers with name containing certain characters... X-Git-Tag: release-1.7rc1~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff862e509f88a9ae96ab953fddfebe60cd3d8a0b;p=thirdparty%2Fcups.git AirPrint: Printers with name containing certain characters are not recognized 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 --- diff --git a/CHANGES-1.6.txt b/CHANGES-1.6.txt index cf564acb13..998b07a893 100644 --- a/CHANGES-1.6.txt +++ b/CHANGES-1.6.txt @@ -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 () - Added support for RFC 6874's IPv6 link local address format in URIs () - The USB backend could crash on libusb-based systems if USB was diff --git a/cups/http-support.c b/cups/http-support.c index 3e974bc66d..ba504823d7 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -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); } } diff --git a/cups/testhttp.c b/cups/testhttp.c index 3599cea47d..4d0ee474a4 100644 --- a/cups/testhttp.c +++ b/cups/testhttp.c @@ -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",