diff options
author | Martin Negyokru <negyokru@inf.u-szeged.hu> | 2023-06-06 15:53:46 +0200 |
---|---|---|
committer | Martin Negyokru <negyokru@inf.u-szeged.hu> | 2023-06-12 19:33:38 +0000 |
commit | 4a79ac857cb675abbd989f5b9ae21dea8016e74e (patch) | |
tree | 89f486ff7bd83db7264a1dff7f110c681d878693 /tests | |
parent | fc86aaa6c0eda5246eb1d03c1c53884c64104976 (diff) |
Validate QNetworkProxy::applicationProxy configs
Invalid proxy settings may result in a crash in chromium.
Use chromium's helper function that validates proxy configs
instead of constructing net::ProxyServer manually.
On invalid input, result will be a `SCHEME_INVALID` ProxyServer.
Fixes: QTBUG-113992
Pick-to: 6.5 6.6
Change-Id: I1745ae3c3cd4da40d3d8b92a14f752ac9b3f8d31
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/proxy/tst_proxy.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/auto/widgets/proxy/tst_proxy.cpp b/tests/auto/widgets/proxy/tst_proxy.cpp index f378ae22f..3dc72618c 100644 --- a/tests/auto/widgets/proxy/tst_proxy.cpp +++ b/tests/auto/widgets/proxy/tst_proxy.cpp @@ -8,7 +8,7 @@ #include <QWebEnginePage> #include <QWebEngineView> #include <QWebEngineUrlRequestInterceptor> - +#include <QWebEngineLoadingInfo> struct Interceptor : public QWebEngineUrlRequestInterceptor { @@ -28,6 +28,7 @@ public: private slots: void proxyAuthentication(); void forwardCookie(); + void invalidHostName(); }; @@ -72,6 +73,19 @@ void tst_Proxy::forwardCookie() QTRY_VERIFY2(cookieSpy.size() > 0, "Could not get cookie"); } +// Crash test ( https://bugreports.qt.io/browse/QTBUG-113992 ) +void tst_Proxy::invalidHostName() +{ + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::HttpProxy); + proxy.setHostName("999.0.0.0"); + QNetworkProxy::setApplicationProxy(proxy); + QWebEnginePage page; + QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool))); + page.load(QUrl("http://www.qt.io")); + QTRY_COMPARE_WITH_TIMEOUT(loadSpy.size(), 1, 20000); +} + #include "tst_proxy.moc" QTEST_MAIN(tst_Proxy) |