Permalink
Browse files

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

  • Loading branch information...
peterix committed Dec 14, 2018
1 parent 14bb666 commit 4a4ba954edb407f0d96073440be5c1834b21a342
Showing with 14 additions and 4 deletions.
  1. +14 −4 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.

0 comments on commit 4a4ba95

Please sign in to comment.