diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2025-04-22 14:56:17 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-04-22 15:09:10 +0300 |
commit | cdfd20709351da8c71a6c295fd1b71ca10fad2cc (patch) | |
tree | a253f117ab1bfb0ce150788a7cb9b073e62b4a7f /library/cpp | |
parent | f6a7f46f175645293ba8fa4651544a47179bc7a6 (diff) | |
download | ydb-cdfd20709351da8c71a6c295fd1b71ca10fad2cc.tar.gz |
Intermediate changes
commit_hash:d92446f14c476da0a2e64664e0a97455e4d5d32a
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/neh/location.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/library/cpp/neh/location.cpp b/library/cpp/neh/location.cpp index 36c08466736..080113949ed 100644 --- a/library/cpp/neh/location.cpp +++ b/library/cpp/neh/location.cpp @@ -4,15 +4,38 @@ using namespace NNeh; +namespace { + bool IsHttps(TStringBuf scheme) { + return TStringBuf("https") == scheme || TStringBuf("fulls") == scheme || TStringBuf("posts") == scheme; + } + + bool SplitUserInfo(TStringBuf& path, TStringBuf& userInfo, bool mayHaveSpecificUserInfo) { + const size_t pos = path.find_first_of(mayHaveSpecificUserInfo ? TStringBuf("?@") : TStringBuf("?@/")); + + if (TStringBuf::npos != pos && '@' == path[pos]) { + if (mayHaveSpecificUserInfo) { + if (!(path.StartsWith("cert=") || path.StartsWith("key="))) { + return false; + } + } + + path.SplitAt(pos, userInfo, path); + path.Skip(1); + } + + return true; + } +} + TParsedLocation::TParsedLocation(TStringBuf path) { path.Split(':', Scheme, path); path.Skip(2); - const size_t pos = path.find_first_of(TStringBuf("?@")); - - if (TStringBuf::npos != pos && '@' == path[pos]) { - path.SplitAt(pos, UserInfo, path); - path.Skip(1); + // try to handle both https://cert=./path_to_cert@host:port/... (userinfo is "cert=./path_to_cert") + // and http[s]://host:port/@zzz (userinfo is empty, host is host, not zzz + // see SEARCH-14238 + if (!SplitUserInfo(path, UserInfo, IsHttps(Scheme))) { + SplitUserInfo(path, UserInfo, false); } auto checkRange = [](size_t b, size_t e){ @@ -43,7 +66,7 @@ TParsedLocation::TParsedLocation(TStringBuf path) { ui16 TParsedLocation::GetPort() const { if (!Port) { - return TStringBuf("https") == Scheme || TStringBuf("fulls") == Scheme || TStringBuf("posts") == Scheme ? 443 : 80; + return IsHttps(Scheme) ? 443 : 80; } return FromString<ui16>(Port); |