GH-2488 fix Qt's relative URL redirect problems some more

This commit is contained in:
Petr Mrázek 2018-12-14 02:48:55 +01:00
parent 14bb666a20
commit 4a4ba954ed

View File

@ -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.