From 0d0f51610c314915ffa5980aff2788d13622ee2b Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 23 Jun 2019 15:15:56 +0000 Subject: [PATCH] Remove userinfo support from old protocols (#419) 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/anyp/Uri.cc b/src/anyp/Uri.cc index 12b1aafd41..6ce8d9ba25 100644 --- a/src/anyp/Uri.cc +++ b/src/anyp/Uri.cc @@ -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); } -- 2.47.2