Bug 1502462 - The altSrv checker does not build a uri correctly if origin is ipv6 address. r=valentin

AltSvcMapping::ProcessHeader should use GetAsciiHost instead of GetHost.

Differential Revision: https://phabricator.services.mozilla.com/D13066

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dragana Damjanovic 2018-11-29 10:15:13 +00:00
Родитель 6cc34ca969
Коммит f4cda9e92e
2 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -942,7 +942,17 @@ AltSvcCache::UpdateAltServiceMapping(AltSvcMapping *map, nsProxyInfo *pi,
}
} else {
// for http:// resources we fetch .well-known too
nsAutoCString origin (NS_LITERAL_CSTRING("http://") + map->OriginHost());
nsAutoCString origin (NS_LITERAL_CSTRING("http://"));
// Check whether origin is an ipv6 address. In that case we need to add
// '[]'.
if (map->OriginHost().FindChar(':') != kNotFound) {
origin.Append('[');
origin.Append(map->OriginHost());
origin.Append(']');
} else {
origin.Append(map->OriginHost());
}
if (map->OriginPort() != NS_HTTP_DEFAULT_PORT) {
origin.Append(':');
origin.AppendInt(map->OriginPort());

Просмотреть файл

@ -2169,7 +2169,7 @@ nsHttpChannel::ProcessAltService()
nsAutoCString originHost;
int32_t originPort = 80;
mURI->GetPort(&originPort);
if (NS_FAILED(mURI->GetHost(originHost))) {
if (NS_FAILED(mURI->GetAsciiHost(originHost))) {
return;
}