qnetworkproxy_mac - do not use the deprecated API

CFURLStringByAddingXXX was deprecated, so we use QUrl combined
with existing QString-based converters (from/to CFStringRef).

Pick-to: 5.15
Task-number: QTBUG-83992
Change-Id: I6f1a3fdafa9532bb7816a1262169df3421169cb7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Timur Pocheptsov 2020-05-05 16:35:59 +02:00
parent 1e25b81e0d
commit c163ec1dbf

View File

@ -203,6 +203,15 @@ void proxyAutoConfigCallback(void *client, CFArrayRef proxylist, CFErrorRef erro
info->proxies = proxylist;
}
}
QCFType<CFStringRef> stringByAddingPercentEscapes(CFStringRef originalPath)
{
Q_ASSERT(originalPath);
const auto qtPath = QString::fromCFString(originalPath);
const auto escaped = QString::fromUtf8(QUrl::toPercentEncoding(qtPath));
return escaped.toCFString();
}
} // anon namespace
QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
@ -228,9 +237,7 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
// kSCPropNetProxiesProxyAutoConfigURLString returns the URL string
// as entered in the system proxy configuration dialog
CFStringRef pacLocationSetting = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString);
QCFType<CFStringRef> cfPacLocation = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, pacLocationSetting, NULL, NULL,
kCFStringEncodingUTF8);
auto cfPacLocation = stringByAddingPercentEscapes(pacLocationSetting);
QCFType<CFDataRef> pacData;
QCFType<CFURLRef> pacUrl = CFURLCreateWithString(kCFAllocatorDefault, cfPacLocation, NULL);
if (!pacUrl) {