Index: cups/http.c =================================================================== --- cups/http.c (revision 8571) +++ cups/http.c (working copy) @@ -1889,18 +1889,38 @@ else if (field == HTTP_FIELD_HOST) { /* - * Special-case for Host: as we don't want a trailing "." on the hostname. + * Special-case for Host: as we don't want a trailing "." on the hostname and + * need to bracket IPv6 numeric addresses. */ - char *ptr = http->fields[HTTP_FIELD_HOST]; - /* Pointer into Host: field */ + if (strchr(value, ':')) + { + /* + * Bracket IPv6 numeric addresses... + * + * This is slightly inefficient (basically copying twice), but is an edge + * case and not worth optimizing... + */ - if (*ptr) + snprintf(http->fields[HTTP_FIELD_HOST], + sizeof(http->fields[HTTP_FIELD_HOST]), "[%s]", value); + } + else { - ptr += strlen(ptr) - 1; + /* + * Check for a trailing dot on the hostname... + */ - if (*ptr == '.') - *ptr = '\0'; + char *ptr = http->fields[HTTP_FIELD_HOST]; + /* Pointer into Host: field */ + + if (*ptr) + { + ptr += strlen(ptr) - 1; + + if (*ptr == '.') + *ptr = '\0'; + } } } }