|
4 | 4 |
|
5 | 5 | using namespace NNeh;
|
6 | 6 |
|
| 7 | +namespace { |
| 8 | + bool IsHttps(TStringBuf scheme) { |
| 9 | + return TStringBuf("https") == scheme || TStringBuf("fulls") == scheme || TStringBuf("posts") == scheme; |
| 10 | + } |
| 11 | + |
| 12 | + bool SplitUserInfo(TStringBuf& path, TStringBuf& userInfo, bool mayHaveSpecificUserInfo) { |
| 13 | + const size_t pos = path.find_first_of(mayHaveSpecificUserInfo ? TStringBuf("?@") : TStringBuf("?@/")); |
| 14 | + |
| 15 | + if (TStringBuf::npos != pos && '@' == path[pos]) { |
| 16 | + if (mayHaveSpecificUserInfo) { |
| 17 | + if (!(path.StartsWith("cert=") || path.StartsWith("key="))) { |
| 18 | + return false; |
| 19 | + } |
| 20 | + } |
| 21 | + |
| 22 | + path.SplitAt(pos, userInfo, path); |
| 23 | + path.Skip(1); |
| 24 | + } |
| 25 | + |
| 26 | + return true; |
| 27 | + } |
| 28 | +} |
| 29 | + |
7 | 30 | TParsedLocation::TParsedLocation(TStringBuf path) {
|
8 | 31 | path.Split(':', Scheme, path);
|
9 | 32 | path.Skip(2);
|
10 | 33 |
|
11 |
| - const size_t pos = path.find_first_of(TStringBuf("?@")); |
12 |
| - |
13 |
| - if (TStringBuf::npos != pos && '@' == path[pos]) { |
14 |
| - path.SplitAt(pos, UserInfo, path); |
15 |
| - path.Skip(1); |
| 34 | + // try to handle both https://cert=./path_to_cert@host:port/... (userinfo is "cert=./path_to_cert") |
| 35 | + // and http[s]://host:port/@zzz (userinfo is empty, host is host, not zzz |
| 36 | + // see SEARCH-14238 |
| 37 | + if (!SplitUserInfo(path, UserInfo, IsHttps(Scheme))) { |
| 38 | + SplitUserInfo(path, UserInfo, false); |
16 | 39 | }
|
17 | 40 |
|
18 | 41 | auto checkRange = [](size_t b, size_t e){
|
@@ -43,7 +66,7 @@ TParsedLocation::TParsedLocation(TStringBuf path) {
|
43 | 66 |
|
44 | 67 | ui16 TParsedLocation::GetPort() const {
|
45 | 68 | if (!Port) {
|
46 |
| - return TStringBuf("https") == Scheme || TStringBuf("fulls") == Scheme || TStringBuf("posts") == Scheme ? 443 : 80; |
| 69 | + return IsHttps(Scheme) ? 443 : 80; |
47 | 70 | }
|
48 | 71 |
|
49 | 72 | return FromString<ui16>(Port);
|
|
0 commit comments