]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove userinfo support from old protocols (#419)
authorAmos Jeffries <yadij@users.noreply.github.com>
Sun, 23 Jun 2019 15:15:56 +0000 (15:15 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 28 Jun 2019 03:10:37 +0000 (03:10 +0000)
RFC 1738 defines the URL schemes for gopher and wais as not
having the userinfo@ segment.

coap, coaps, whois and cache_object also do not use this segment.

For these cases we can obey the RFC7230 requirement to ignore the
segment when producing normalized absolute URL.

Of the supported protocols only FTP requires userinfo, and because
we cannot be certain for unknown protocols allow it as well.

src/anyp/Uri.cc

index 12b1aafd410f009387f0f7653e48d719a3f03835..6ce8d9ba2588dcfc6b835f3c120d88ccda71e7ac 100644 (file)
@@ -495,10 +495,10 @@ AnyP::Uri::absolute() const
         absolute_.append(":",1);
         if (getScheme() != AnyP::PROTO_URN) {
             absolute_.append("//", 2);
-            const bool omitUserInfo = getScheme() == AnyP::PROTO_HTTP ||
-                                      getScheme() == AnyP::PROTO_HTTPS ||
-                                      userInfo().isEmpty();
-            if (!omitUserInfo) {
+            const bool allowUserInfo = getScheme() == AnyP::PROTO_FTP ||
+                                       getScheme() == AnyP::PROTO_UNKNOWN;
+
+            if (allowUserInfo && !userInfo().isEmpty()) {
                 absolute_.append(userInfo());
                 absolute_.append("@", 1);
             }