summaryrefslogtreecommitdiffstats
path: root/api/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-12-14 02:48:55 +0100
committerPetr Mrázek <peterix@gmail.com>2018-12-14 02:48:55 +0100
commit4a4ba954edb407f0d96073440be5c1834b21a342 (patch)
tree347ff441665a0c190f88bd96d1ffe841f9538ab5 /api/logic
parent14bb666a207ee76cf302152aa03579a47ef32215 (diff)
downloadMultiMC-4a4ba954edb407f0d96073440be5c1834b21a342.tar
MultiMC-4a4ba954edb407f0d96073440be5c1834b21a342.tar.gz
MultiMC-4a4ba954edb407f0d96073440be5c1834b21a342.tar.lz
MultiMC-4a4ba954edb407f0d96073440be5c1834b21a342.tar.xz
MultiMC-4a4ba954edb407f0d96073440be5c1834b21a342.zip
GH-2488 fix Qt's relative URL redirect problems some more
Diffstat (limited to 'api/logic')
-rw-r--r--api/logic/net/Download.cpp18
1 files changed, 14 insertions, 4 deletions
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.