From 4a4ba954edb407f0d96073440be5c1834b21a342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 14 Dec 2018 02:48:55 +0100 Subject: GH-2488 fix Qt's relative URL redirect problems some more --- api/logic/net/Download.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'api') diff --git a/api/logic/net/Download.cpp b/api/logic/net/Download.cpp index fc634e3d..ccdc2c7d 100644 --- a/api/logic/net/Download.cpp +++ b/api/logic/net/Download.cpp @@ -167,14 +167,24 @@ bool Download::handleRedirect() } QString redirectStr = QString::fromUtf8(redirectBA); - /* - * IF the URL begins with //, we need to insert the URL scheme. - * See: https://bugreports.qt-project.org/browse/QTBUG-41061 - */ if(redirectStr.startsWith("//")) { + /* + * IF the URL begins with //, we need to insert the URL scheme. + * See: https://bugreports.qt.io/browse/QTBUG-41061 + * See: http://tools.ietf.org/html/rfc3986#section-4.2 + */ redirectStr = m_reply->url().scheme() + ":" + redirectStr; } + else if(redirectStr.startsWith("/")) + { + /* + * IF the URL begins with /, we need to process it as a relative URL + */ + auto url = m_reply->url(); + url.setPath(redirectStr, QUrl::TolerantMode); + redirectStr = url.toString(); + } /* * Next, make sure the URL is parsed in tolerant mode. Qt doesn't parse the location header in tolerant mode, which causes issues. -- cgit v1.2.3