summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2020-05-05 16:35:59 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2020-07-06 13:54:11 +0200
commitc163ec1dbf873781b77ea67d4449d643c166c0c4 (patch)
treeaba8be936a82c8c45031ae5689f8c7bd88fee95a /src/network
parent1e25b81e0d6c1da4643c9cc48680f5cc4399d068 (diff)
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>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/kernel/qnetworkproxy_mac.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp
index 3fcd9299f3..e4d2663f7a 100644
--- a/src/network/kernel/qnetworkproxy_mac.cpp
+++ b/src/network/kernel/qnetworkproxy_mac.cpp
@@ -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) {