diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2013-06-25 01:42:48 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2013-06-25 01:42:48 +0000 |
commit | ff862e509f88a9ae96ab953fddfebe60cd3d8a0b (patch) | |
tree | a1ebd30d2ad13c693c3f5bd44eaf063262b0b148 /cups/http-support.c | |
parent | 71f294cef9c3bcdacb093984bccca1c016527c7e (diff) | |
download | cups-ff862e509f88a9ae96ab953fddfebe60cd3d8a0b.tar.gz |
<rdar://problem/14243133> 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
Diffstat (limited to 'cups/http-support.c')
-rw-r--r-- | cups/http-support.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/cups/http-support.c b/cups/http-support.c index 3e974bc66..ba504823d 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); } } |