Merge pull request #1273 from csware/issue-1266

WebView: Properly handle usernames with spaces and plus signs in it
This commit is contained in:
Roeland Jago Douma 2019-05-23 19:59:49 +02:00 committed by GitHub
commit ea6f3be374
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -136,7 +136,7 @@ WebViewPageUrlSchemeHandler::WebViewPageUrlSchemeHandler(QObject *parent)
void WebViewPageUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request) {
QUrl url = request->requestUrl();
QString path = url.path().mid(1);
QString path = url.path(0).mid(1); // get undecoded path
QStringList parts = path.split("&");
QString server;
@ -153,12 +153,14 @@ void WebViewPageUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *reques
}
}
user = QUrl::fromPercentEncoding(user.toUtf8());
password = QUrl::fromPercentEncoding(password.toUtf8());
qCDebug(lcWizardWebiew()) << "Got raw user from request path: " << user;
user = user.replace(QChar('+'), QChar(' '));
password = password.replace(QChar('+'), QChar(' '));
user = QUrl::fromPercentEncoding(user.toUtf8());
password = QUrl::fromPercentEncoding(password.toUtf8());
if (!server.startsWith("http://") && !server.startsWith("https://")) {
server = "https://" + server;
}