--------------------- PatchSet 4589 Date: 2007/05/18 07:32:50 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: Reverse IPv4 capability of handling [] addresses in URI. Seems the downstream code assumes everthing there is a FQDN and can't cope with proper IPA-hostnames anyway. IPv4 only gets away with it by having the same format as a FQDN. Members: src/url.cc:1.9.8.16->1.9.8.17 src/tests/testHttpRequest.cc:1.1.14.5->1.1.14.6 Index: squid3/src/url.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/url.cc,v retrieving revision 1.9.8.16 retrieving revision 1.9.8.17 diff -u -r1.9.8.16 -r1.9.8.17 --- squid3/src/url.cc 18 May 2007 04:03:40 -0000 1.9.8.16 +++ squid3/src/url.cc 18 May 2007 07:32:50 -0000 1.9.8.17 @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.9.8.16 2007/05/18 04:03:40 amosjeffries Exp $ + * $Id: url.cc,v 1.9.8.17 2007/05/18 07:32:50 amosjeffries Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -119,7 +119,7 @@ /* more cases? */ } -/* +/** * urlParseProtocol() takes begin (b) and end (e) pointers, but for * backwards compatibility, e defaults to NULL, in which case we * assume b is NULL-terminated. @@ -320,16 +320,23 @@ /* Is there any host information? (we should eventually parse it above) */ if(*host == '[') { - /* strip any IPA brackets. valid under IPv6 and IPv4 (although rare to non-existent) */ + /* strip any IPA brackets. valid under IPv6. */ + dst = host; +#if USE_IPV6 + /* only for IPv6 sadly, pre-IPv6/URL code can't handle the clean result properly anyway. */ src = host; src++; l = strlen(host); i = 1; - for (dst = host; i < l && *src != ']' && *src != '\0'; i++, src++, dst++) { + for (; i < l && *src != ']' && *src != '\0'; i++, src++, dst++) { *dst = *src; } /* we moved in-place, so truncate the actual hostname found */ *(dst++) = '\0'; +#else + /* IPv4-pure needs to skip the whole hostname to ']' inclusive for now */ + while(*dst != '\0' && *dst != ']') dst++; +#endif /* skip ahead to either start of port, or original EOS */ while(*dst != '\0' && *dst != ':') dst++; Index: squid3/src/tests/testHttpRequest.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/tests/testHttpRequest.cc,v retrieving revision 1.1.14.5 retrieving revision 1.1.14.6 diff -u -r1.1.14.5 -r1.1.14.6 --- squid3/src/tests/testHttpRequest.cc 18 May 2007 04:03:40 -0000 1.1.14.5 +++ squid3/src/tests/testHttpRequest.cc 18 May 2007 07:32:50 -0000 1.1.14.6 @@ -134,7 +134,13 @@ expected_port = 80; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT_EQUAL(METHOD_GET, aRequest->method); +#if USE_IPV6 + /* We hasve fixed this in IPv6 build. */ CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); +#else + /* NO fix is possible in IPv4-pure build. */ + CPPUNIT_ASSERT_EQUAL(String("2000:800::45"), String(aRequest->GetHost())); +#endif CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://2000:800::45/foo"), String(url));