summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Lösch <Sebastian.Loesch@governikus.de>2016-03-31 15:09:20 +0200
committerSebastian Lösch <Sebastian.Loesch@governikus.com>2016-04-07 08:38:21 +0000
commit7d1e6ca1998f6fd26795b1f9e408ccd7c7c0b558 (patch)
treea982c395b34f12824ca29382d8f1843f1a9c4e2b
parent5b17fb14282822de36efd924abff8e3555e2491f (diff)
Limit URLs for proxy auto config to 2083 chars
On Windows only URLs up to 2083 characters are supported, so longer URLs are truncated. Task-number: QTBUG-52271 Change-Id: I625e4d089df4d977d39e61e5831611e04260e729 Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index 9e571bfe7f..15ef7d7cee 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -41,6 +41,7 @@
#include <qurl.h>
#include <private/qsystemlibrary_p.h>
#include <qnetworkinterface.h>
+#include <qdebug.h>
#include <string.h>
#include <qt_windows.h>
@@ -590,8 +591,16 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
url.setScheme(QLatin1String("https"));
}
+ QString urlQueryString = url.toString();
+ if (urlQueryString.size() > 2083) {
+ // calls to WinHttpGetProxyForUrl with urls longer than 2083 characters
+ // fail with error code ERROR_INVALID_PARAMETER(87), so we truncate it
+ qWarning("Proxy query URL too long for windows API, try with truncated URL");
+ urlQueryString = url.toString().left(2083);
+ }
+
bool getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
- (LPCWSTR)url.toString().utf16(),
+ (LPCWSTR)urlQueryString.utf16(),
&sp->autoProxyOptions,
&proxyInfo);
DWORD getProxyError = GetLastError();
@@ -608,7 +617,7 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
sp->autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
sp->autoProxyOptions.lpszAutoConfigUrl = (LPCWSTR)sp->autoConfigUrl.utf16();
getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
- (LPCWSTR)url.toString().utf16(),
+ (LPCWSTR)urlQueryString.utf16(),
&sp->autoProxyOptions,
&proxyInfo);
getProxyError = GetLastError();
@@ -621,7 +630,7 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
// But now we've to enable it (http://msdn.microsoft.com/en-us/library/aa383153%28v=VS.85%29.aspx)
sp->autoProxyOptions.fAutoLogonIfChallenged = TRUE;
getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
- (LPCWSTR)url.toString().utf16(),
+ (LPCWSTR)urlQueryString.utf16(),
&sp->autoProxyOptions,
&proxyInfo);
getProxyError = GetLastError();